Basically there are 2 methods how we can define strings,
- Simple strings
- Complex strings
In a php interview, even a well experienced php programmer might forget how this works,
For an example,
a) echo “Hello $what\n”;
b) echo ‘Hello $what\n’;
$what = “World”;
Which will print correctly in to the browser as “Hello World” followed by a new line.
Is it a) or b) ?
The answer is “a”. That is because simple string will print almost all characters literally, where complex string allows special escape sequences to insert special characters.