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? Link to comment https://forums.phpfreaks.com/topic/296076-problem-using-variable-in-heredoc/ Share on other sites More sharing options...
Ch0cu3r Posted May 5, 2015 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. 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 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
Archived
This topic is now archived and is closed to further replies.