Posted: Sat Sep 01, 2007 11:12 pm
And yet another way it can be done:
Code: Select all
$str = 'little';
printf('Mart had a %s lamb.', $str);A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
$str = 'little';
printf('Mart had a %s lamb.', $str);Code: Select all
// when code execution reaches this statement php concatenates the three strings
$s = 'Mary had a ' . $i . ' lamb.';
// when code execution reaches this statement php executes printf
// and printf "replaces" %s with the value of its second parameter
printf('Mart had a %s lamb.', $str);
// when code execution reaches this statement php "replaces" $i
// by the contents of the variable i
$s = "Mary had a $i lamb.";Code: Select all
<?php
$i = 1234;
echo <<< dfh
- $i -
dfh;
echo '- $i -';
echo "- $i -";OK. I'll try and tell you immediately.volka wrote:trysee also: http://de2.php.net/stringCode: Select all
<?php $i = 1234; echo <<< dfh - $i - dfh; echo '- $i -'; echo "- $i -";
heredocs and double quote print the value of i.volka wrote:trysee also: http://de2.php.net/stringCode: Select all
<?php $i = 1234; echo <<< dfh - $i - dfh; echo '- $i -'; echo "- $i -";