cloudll Posted May 5, 2015 Share Posted May 5, 2015 I am trying to use a variable in heredoc to absolutley position a css div. position: absolute; top:$pos_ypx; left:$pos_xpx; The problem is, as it looks at the moment, it thinks the variable name is $pos_xpx and not just $pos_x. If i leave a space ($pos_x px) the css does not work. Is there anyway to make php ignore the px part when calling the variable? Quote Link to comment https://forums.phpfreaks.com/topic/296076-problem-using-variable-in-heredoc/ Share on other sites More sharing options...
Solution Ch0cu3r Posted May 5, 2015 Solution Share Posted May 5, 2015 You need to wrap your variables in curly braces. position: absolute; top:{$pos_y}px; left:{$pos_x}px; If you do not then php will think the px is part of the variable name. Quote Link to comment https://forums.phpfreaks.com/topic/296076-problem-using-variable-in-heredoc/#findComment-1510812 Share on other sites More sharing options...
cloudll Posted May 5, 2015 Author Share Posted May 5, 2015 your awesome thanks Quote Link to comment https://forums.phpfreaks.com/topic/296076-problem-using-variable-in-heredoc/#findComment-1510813 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.