String literals

PHP can create double- and single-quoted string literals. If double quotation marks are needed as part of a string, the easiest approach is to switch to the single-quotation style:

echo 'This works';
echo "just like this.";
// And here are some strings that contain quotes
echo "This string has a ': a single quote!";
echo 'This string has a ": a double quote!';

Escaping Quotation marks

Quotation marks can be escaped like this:

echo "This string has a \": a double quote!";
echo 'This string has a \': a single quote!';

One of the convenient features of PHP is the ability to include the value of a variable in a string literal. PHP parses double-quoted strings and replaces variable names with the variable's value. The following example shows how: