ID:               31051
 Updated by:       [EMAIL PROTECTED]
 Reported By:      michael at fishnet dot us
-Status:           Open
+Status:           Bogus
 Bug Type:         Output Control
 Operating System: linux 2.4.20
 PHP Version:      4.3.10RC2
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You're echo-ing the result of printf -- since printf *outputs* the
formatted value and *returns* the number of characters output, you're
seeing the output from printf (the formatted number) followed by the
output from echo (the length of the printf output).


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

[2004-12-10 08:31:54] michael at fishnet dot us

Description:
------------
printf() occasionally returns unexpected trailing characters.  The
problem can be difficult to reproduce, as it only rarely happens.  The
example URL below does show the problem.  I have never isolated just
what causes the format problem, though so far the extraneous characters
seem to only occur in floating point formats.  Others have reported the
same random behaviour on the FishCart (http://fishcart.org/) support
list, from which the example code below is derived.

In the example URL below there is a link to view the exact PH P source
that prints the page; this should allow testing the script on other
servers and other versions.  This server is running on 4.3.10RC2; it
also happened on 4.3.10RC1, 4.3.9 and is also reproducable on a
different server running 5.0.2.

Reproduce code:
---------------
http://www.fni.com/sprintf_4310rc2.php
http://www.fni.com/sprintf_4310rc2.txt

Expected result:
----------------
A few integer and floating point numbers are displayed that should show
both integers and floating point numbers formatted to 2 decimal places.

Actual result:
--------------
When displaying 42, the printed result is 42.009.  When printing 39
with 0 to 3 trailing spaces in the format string, an ascending count is
displayed as follows; the increasing appended number (9, 10, 11, 12)
seems to be the overall displayed string length including the $.

$ 39.009
$ 39.00 10
$ 39.00  11
$ 39.00   12

See the script source code in the URL above to see exactly what code is
being run.  In particular, look at the page source in the browser to see
how the above numbers are staggered.


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


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

Reply via email to