note 40147 deleted from function.printf by tomsommer
| From: | tomsommer@php.net | Date: | Sat, 10 Jul 2004 00:03:13 +0000 |
| Subject: | note 40147 deleted from function.printf by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72949@lists.php.net to get a copy of this message | ||
Note Submitter: chris.breen@accurate.com
----
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