php var in string code example
Example 1: php connect strings
$string3 = $string1 . $string2;
Example 2: php variable in string
$a = '12345';
echo "qwe{$a}rty";
echo "qwe" . $a . "rty";
echo 'qwe{$a}rty';
echo "qwe$arty";
Example 3: PHP Variable in String
phpCopy# php 7.*
<?php
$txt = "salt";
echo "{$txt}y";
?>
Example 4: PHP Variable in String
phpCopy#php 7.x
<?php
$prefix = "Comfort";
$suffix = "able";
echo "{$prefix}{$suffix}";
?>
Example 5: PHP Variable in String
phpCopy#php 7.x
<?php
$taste = "ie";
echo sweet.$taste;
?>