1.

How To Include Variables In Double-quoted Strings?

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\n";
echo "part 1 ".$variable." part 2\n";
?>
This script will print:
part 1 and part 2
part 1 and part 2

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\n";
echo "part 1 ".$variable." part 2\n";
?>
This script will print:
part 1 and part 2
part 1 and part 2



Discussion

No Comment Found