In this tutorial, you shall learn how to specify or include a variable in a string in PHP, with the help of example programs.
PHP – Variable in a string
To specify or include a variable in a string in PHP, wrap the variable in curly braces. Also, please make sure to use double quotes to write the string literal.
ADVERTISEMENT
Syntax
The syntax to include the variable $name in a string is
"hello {$name}"
The expression interpolates the variable $name
directly in the string.
Example
In the following program, we take a value in variable $name
, include it in the string, and echo the string to output.
PHP Program
<?php $name = "Arjun"; echo "hello {$name}"; ?>
Output

Conclusion
In this PHP Tutorial, we learned how to include a variable in a string using curly braces notation.