note 86530 deleted from function.sprintf by danbrown
| From: | danbrown@php.net | Date: | Thu, 23 Oct 2008 16:06:59 +0000 |
| Subject: | note 86530 deleted from function.sprintf by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-145652@lists.php.net to get a copy of this message | ||
Note Submitter: theladz at fastmail dot fm
----
<?php
// Heredoc & sprintf anomalies
// This works
$number = 5;
$location = 'tree';
echo sprintf(<<<EOD
The %s contains %d monkeys. A nice %s full of %d monkeys.
EOD
, $location
, $number
, $location
, $number
);
// Positional placemarkers don't work when using the Heredoc syntax
// This DOESN'T work
echo sprintf(<<<EOD
The %2$s contains %1$d monkeys. A nice %2$s full of %1$d monkeys.
EOD
, $number
, $location
);
?>