Single and Double Quotes in PHP

Single quotes

$singleQuoteExample = 'I am learning $language.';

Output: I am learning $language.

Double quotes

$doubleQuoteExample = "I am learning $language.";

Output: I am learning PHP.

Explanation

Both types of quotes create strings, but PHP treats their contents differently. Single quotes usually show a variable name as ordinary text, so the dollar sign and name remain visible. Double quotes substitute the variable's value, which is why the second output says PHP. Double quotes also interpret escape sequences such as a newline.

Back to Activity 3