WordPress Development Question:
Download Questions PDF

Why doesn't the following code print the newline properly?


$str = 'Hello, there.nHow are you?nThanks for visiting Us';
print $str;
Because inside the single quotes the n character is not interpreted as newline, just as a sequence of two characters - and n.

Download WordPress Expert Interview Questions And Answers PDF

Previous QuestionNext Question
Would you initialize strings with single quotes or double quotes?How come code
<?php print "Contents: $arr[1]"; ?>
works, but
<?php print "Contents: $arr[1][2]"; ?>
doesn't for two-dimensional array of mine?