Answers for "php variable in string"

PHP
2

php variable in string

$a = '12345';

// This works:
echo "qwe{$a}rty"; // qwe12345rty, using braces
echo "qwe" . $a . "rty"; // qwe12345rty, concatenation used

// Does not work:
echo 'qwe{$a}rty'; // qwe{$a}rty, single quotes are not parsed
echo "qwe$arty"; // qwe, because $a became $arty, which is undefined
Posted by: Guest on March-14-2021
1

php connect strings

$string3 = $string1 . $string2;
Posted by: Guest on October-08-2020
10

php variables

<?php
  $string = 'string';
  $number = 1;
?>
Posted by: Guest on October-02-2020
0

PHP Variable in String

phpCopy# php 7.*
<?php
$txt = "salt";
echo "{$txt}y";
?>
Posted by: Guest on April-23-2021
0

PHP Variable in String

phpCopy#php 7.x
<?php
$prefix = "Comfort";
$suffix = "able";
echo "{$prefix}{$suffix}";
?>
Posted by: Guest on April-23-2021
0

PHP Variable in String

phpCopy#php 7.x
<?php
$taste = "ie";
echo sweet.$taste;
?>
Posted by: Guest on April-23-2021

Browse Popular Code Answers by Language