dsaba Posted April 8, 2007 Share Posted April 8, 2007 i'm defining a variable with heredoc syntax like so: $imageurl = "http://myimageurl.jpg"; $var = <<<VAR <img src="$imageurl"> VAR; later in my script I say: $imageurl = "http://newimageurl.jpg"; echo $var; will it echo <img src="http://newimageurl.jpg"> OR <img src="http://myimageurl.jpg"> ?? also what if i reference an undefined variable in my heredox syntax, and then later define it? -thanks Link to comment https://forums.phpfreaks.com/topic/46103-solved-heredox-syntax-with-newly-defined-variables-quick-logic-question/ Share on other sites More sharing options...
HaLo2FrEeEk Posted April 8, 2007 Share Posted April 8, 2007 It will echo <img src="http://myimageurl.jpg">, becuase you set $var to the original value of $imageurl, and var did not get reset after you changed the value of $imageurl. If you wanted it to change, you could do this: $imageurl = "http://myimageurl.jpg"; $var = <<<VAR <img src="$imageurl"> VAR; $imageurl = "http://newimageurl.jpg"; echo $var; $var = <<<VAR <img src="$imageurl"> VAR; echo $var; That way it resets $var. Help? Link to comment https://forums.phpfreaks.com/topic/46103-solved-heredox-syntax-with-newly-defined-variables-quick-logic-question/#findComment-224024 Share on other sites More sharing options...
dsaba Posted April 8, 2007 Author Share Posted April 8, 2007 ya thats what i thought thanks there is nothign special with variables inside of heredox syntax and it does not act like functions with variables i will place the heredoc variable into a function so I can define it once, and change the variable as many times as I want, without having to re-define the heredoc variable Link to comment https://forums.phpfreaks.com/topic/46103-solved-heredox-syntax-with-newly-defined-variables-quick-logic-question/#findComment-224026 Share on other sites More sharing options...
HaLo2FrEeEk Posted April 8, 2007 Share Posted April 8, 2007 If this is done then you should mark it as solved. edit: You beat me to it...lol. Link to comment https://forums.phpfreaks.com/topic/46103-solved-heredox-syntax-with-newly-defined-variables-quick-logic-question/#findComment-224028 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.