note 97517 deleted from function.sprintf by danbrown

From: Date: Fri, 23 Apr 2010 19:11:11 +0000
Subject: note 97517 deleted from function.sprintf by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-168573@lists.php.net to get a copy of this message
Note Submitter: nate ---- @kamm: The heredoc syntax works in the double-quoted parsing mode - your example with $format3 is trying to insert variables $s and $d into the string. You either need to escape the $'s with backslashes, or if you are using php >= 5.3.0, use a "nowdoc" instead of a "heredoc" (nowdocs work in single-quoted parsing mode): <?php // heredoc, you need to escape the $'s $format3 = <<<EOD The %2\$s contains %1\$d monkeys EOD; // php >= 5.3.0, use nowdoc (note single // quotes around opening delimeter) $format3 = <<<'EOD' The %2$s contains %1$d monkeys EOD; // either of above works with: $num = 5; $location = 'jungle'; echo sprintf($format3, $num, $location ); ?>

« previous php.notes (#168573) next »