note 40147 added to function.printf
| From: | chris dot breen at accurate dot com | Date: | Mon, 23 Feb 2004 15:16:44 +0000 |
| Subject: | note 40147 added to function.printf | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-65595@lists.php.net to get a copy of this message | ||
This may seem obvious but the variable swapping feature of printf, ie:-
<?php
$format = "The %2\$s contains %1\$d monkeys.
That is a nice %2\$s full of %1\$d monkeys.";
printf($format, $num, $location);
?>
Does not work with single quotes, ie:-
<?php
$format = 'The %2\$s contains %1\$d monkeys.
That is a nice %2\$s full of %1\$d monkeys.';
printf($format, $num, $location);
?>
You will get an error complaining about too few arguments, always use double quotes for variable
swapping
----
Manual Page -- http://www.php.net/manual/en/function.printf.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40147
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40147&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40147&report=yes
Search -- http://master.php.net/manage/user-notes.php