george Posted September 19, 2007 Share Posted September 19, 2007 Where $key and $item are valid text variables containing valid values, Why does this work? echo "$key. $item<br />\n"; I thought the correct code would be echo $key . $item . "<br />\n"; Is php responding to the $ to render the value of the variable even when it is within quotes? I thought that by being in quotes, it would render the literal value of what is quoted, and not the variable content. Link to comment Share on other sites More sharing options...
Kristian_C Posted September 19, 2007 Share Posted September 19, 2007 why it works well, just becouse it is the right way to use it, you chould use : echo"$key . $item .\"<br>\n\""; //but why do you have the \n actually? <br> works just fine dont it? Dont actually understand what the whole challenge thing was about ..-Kristian_C Link to comment Share on other sites More sharing options...
justsomeguy Posted September 19, 2007 Share Posted September 19, 2007 When a string is in double-quotes or heredoc syntax PHP will do variable replacement and replace the non-escaped variables with their values. If the string is single-quoted PHP will not do variable replacement.http://www.php.net/manual/en/language.types.string.php Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.