note 97517 added to function.sprintf

From: Date: Fri, 23 Apr 2010 19:10:40 +0000
Subject: note 97517 added to function.sprintf
Groups: php.notes 
Request: Send a blank email to php-notes+get-168572@lists.php.net to get a copy of this message
@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 ); ?> ---- Server IP: 69.147.83.197 Probable Submitter: 69.70.125.250 ---- Manual Page -- http://www.php.net/manual/en/function.sprintf.php Edit -- https://master.php.net/note/edit/97517 Del: integrated -- https://master.php.net/note/delete/97517/integrated Del: useless -- https://master.php.net/note/delete/97517/useless Del: bad code -- https://master.php.net/note/delete/97517/bad+code Del: spam -- https://master.php.net/note/delete/97517/spam Del: non-english -- https://master.php.net/note/delete/97517/non-english Del: in docs -- https://master.php.net/note/delete/97517/in+docs Del: other reasons-- https://master.php.net/note/delete/97517 Reject -- https://master.php.net/note/reject/97517 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#168572) next »