ID:               36980
 Updated by:       [EMAIL PROTECTED]
 Reported By:      RQuadling at GMail dot com
-Status:           Open
+Status:           Closed
 Bug Type:         Documentation problem
 Operating System: Windows XP
 PHP Version:      Irrelevant
 New Comment:

This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation
better.

BTW there's a mistake on the last modified line of your patch.


Previous Comments:
------------------------------------------------------------------------

[2006-04-05 08:24:03] RQuadling at GMail dot com

Possible patch.

Index: sprintf.xml
===================================================================
RCS file:
/repository/phpdoc/en/reference/strings/functions/sprintf.xml,v
retrieving revision 1.15
diff -u -r1.15 sprintf.xml
--- sprintf.xml 28 Nov 2004 12:42:49 -0000      1.15
+++ sprintf.xml 5 Apr 2006 08:21:45 -0000
@@ -143,7 +143,7 @@
       <programlisting role="php">
 <![CDATA[
 <?php
-$format = "There are %d monkeys in the %s";
+$format = 'There are %d monkeys in the %s';
 printf($format, $num, $location);
 ?>
 ]]>
@@ -158,7 +158,7 @@
       <programlisting role="php">
 <![CDATA[
 <?php
-$format = "The %s contains %d monkeys";
+$format = 'The %s contains %d monkeys';
 printf($format, $num, $location);
 ?>
 ]]>
@@ -174,7 +174,7 @@
       <programlisting role="php">
 <![CDATA[
 <?php
-$format = "The %2\$s contains %1\$d monkeys";
+$format = 'The %2$s contains %1$d monkeys';
 printf($format, $num, $location);
 ?>
 ]]>
@@ -187,8 +187,8 @@
       <programlisting role="php">
 <![CDATA[
 <?php
-$format = "The %2\$s contains %1\$d monkeys.
-           That's a nice %2\$s full of %1\$d monkeys.";
+$format = 'The %2$s contains %1$d monkeys.
+           That's a nice %2$s full of %1$d monkeys.';
 printf($format, $num, $location);
 ?>
 ]]>

------------------------------------------------------------------------

[2006-04-05 08:13:15] RQuadling at GMail dot com

Description:
------------
I have found a bug on page function.sprintf.html
[chm date: 2006-04-03]...

The examples regarding the facility of argument swapping all use double
quotes. As a consequence, the parameters need to escape the $ in the
format so to tell PHP to not evaluate $s.

e.g.

"%1\$s"

As the basic idea here is to use these markers as placeholders for data
from elsewhere, the emphasis is surely that these are plaintext strings,
not strings with embedded variables, otherwise, what's the point of the
function? Yeah, I know formatting, but you can't format a variable if
you supply it IN the string, so hopefully, my reasoning still stands.

The examples should be ...

'%1$s' This makes more sense.

All the examples and a lot of the user notes ALL use the 'suspect'
double quotes.

The user note by moritz dot geselle at invision-team dot de on
02-Dec-2002 10:52
(http://uk2.php.net/manual/en/function.sprintf.php#27346) should be
taken into account and the docs reflect this simply because it is NOT
obvious!





------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=36980&edit=1

Reply via email to