ID: 24872
Updated by: [EMAIL PROTECTED]
Reported By: kostas at nasis dot com
-Status: Open
+Status: Closed
Bug Type: Feature/Change Request
Operating System: Redhat 7.3, 8
PHP Version: 4.3.2
New Comment:
Seems to be fixed in CVS since I get the expected result.
Previous Comments:
------------------------------------------------------------------------
[2003-07-30 09:56:15] kostas at nasis dot com
Description:
------------
sprintf() will return a trailing NULL character under certain
conditions. See code below.
Reproduce code:
---------------
<?php
$blah = sprintf("%04d", -500);
echo "$blah\n";
// display ASCII code for each character of $blah
for ($i = 0; $i < strlen($blah); $i++) {
echo ord($blah{$i}) . "\n";
}
?>
Expected result:
----------------
The code should output:
-500
45
53
48
48
Actual result:
--------------
On PHP v4.3.2 it outputs:
-500
45
53
48
48
0
Notice the NULL (0) character at the end.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24872&edit=1