Memory App

Programming > Php > Basics > String type   ZCE 5.3  |  Patterns  |  Modern Php

Single quotes

Variables are NOT interpreted and replaced.

$a = 'a';

echo $b = '$an'; // outputs $an

Double quotes

Variables are interpreted and replaced.

$a = 'a';

echo $b = "$an"; // output a


Herodoc formating is used for multiple lines. I allowes for the use of quotes without escaping.

$who = "John";
$output = <<<TEST
    She said "This is $who's test"
    on multiple rows

echo nl2br($output);
    She said "This is John's test"
    on multiple rows
Note that the line with the closing identifier must contain no other characters, except possibly a semicolon (;). Also, the first character after the closing identifier must be a newline.

0/0 (80)  
Not Logged