ExpertRefresh

Basics / String type  

1) What is the value of $b ? <?php $a = "a"; $b = '$a n'; echo $b;





2) What is the value of $b ? <?php $a = 'a'; $b = "$a n"; echo $b;








Strings

Single quotes (variables and escape sequences will not be interpreted and replaced) <?php $a = 'a'; echo $b = '$an'; // output $an Double quotes (variables and escape sequences will be interpreted and replaced) <?php $a = 'a'; echo $b = "$an"; // output a Herodoc (for multiple lines). Allow for the use of quotes without escaping. It is very important to note that the line with the closing identifier must contain no other characters, except possibly a semicolon (;). That means especially that the identifier may not be indented, and there may not be any spaces or tabs before or after the semicolon. It's also important to realize that the first character after the closing identifier must be a newline as defined by the local operating system. <?php $who = "John"; $output = <<<TEST She said "This is $who's test" on multiple rows TEST; echo nl2br($output); /* output She said "This is John's test" on multiple rows */


References