Basic PHP Programming Question:

How To Include Variables in Double-Quoted Strings in PHP?

Tweet Share WhatsApp

Answer:

Variables included in double-quoted strings will be interpolated. Their values will be concatenated into the enclosing strings. For example, two statements in the following PHP script will print out the same string:

<?php
$variable = "and";
echo "part 1 $variable part 2 ";
echo "part 1 ".$variable." part 2 ";
?>

This script will print:

part 1 and part 2
part 1 and part 2


Download PHP PDF Read All 139 PHP Questions
Previous QuestionNext Question
How Many Escape Sequences Are Recognized in Double-Quoted Strings in PHP?How Many Ways to Include Variables in Double-Quoted Strings in PHP?