Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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
Source by www.php.net #
 
PREVIOUS NEXT
Tagged: #php #variable #string
ADD COMMENT
Topic
Name
1+9 =