note 86531 deleted from function.sprintf by felipe
| From: | felipe@php.net | Date: | Fri, 24 Oct 2008 11:09:59 +0000 |
| Subject: | note 86531 deleted from function.sprintf by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-145689@lists.php.net to get a copy of this message | ||
Note Submitter: theladz at fastmail dot fm
Reason: 2
----
<?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
);
?>