Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

Single Quotes

Using Single Quotes

Strings are enclosed in quotes, but there is a distinction between single and double quotes in PHP.

When using double quotes, variables can be directly included in the string, as shown in the example above.

In contrast, when using single quotes, variables must be concatenated using the . operator, like this:

Example

$txt1 = "Learn PHP";
$txt2 = "W3Schools.com";

echo
'<h2>' . $txt1 . '</h2>';
echo '<p>Study PHP at ' . $txt2 . '</p>';