CODE:
String in PHP heredoc and nowdoc <?php $beVerb = "is"; $sentence1 = 'My name $beVerb Jim'; echo "Sentence 1 in single quotation"; echo "<br>"; echo $sentence1; echo "<br>"; $sentence2 = "My name $beverb Jim"; echo "Sentence 1 in single quotation<br>"; echo $sentence2; echo "<br>PHP HERE DOC EXAMPLE<br>"; $str = <<<tom the beverb i used $beVerb another test 'this is multiple test' and the be verb is $beVerb another "test" tom; echo $str; echo "<br>PHP NOW DOC EXAMPLE<br>"; $str = <<<'tom' the beverb i used $beVerb another test 'this is multiple test' and the be verb is $beVerb another "test" tom; echo $str; ?>
OUTPUT:
Sentence 1 in single quotation My name $beVerb Jim Sentence 1 in single quotation My name Jim PHP HERE DOC EXAMPLE the beverb i used is another test 'this is multiple test' and the be verb is is another "test" PHP NOW DOC EXAMPLE the beverb i used $beVerb another test 'this is multiple test' and the be verb is $beVerb another "test"
