Singly quoted strings are treated almost literally, whereas doubly quoted strings replace variables with their values as well as specially interpreting certain character sequences.
Copy to Clipboard
1
$variable = "name";
2
$stringEx = 'My $variable will not print!\\n';
3
print($stringEx);
4
$stringEx = "My $variable will print!\\n";
5
print($stringEx);
Output:
Copy to Clipboard
2
1
My $variable will not print!
2
My name will print
Leave A Comment