#24872 [NEW]: sprintf() returns trailing NULL character

From: Date: Wed, 30 Jul 2003 14:56:15 +0000
Subject: #24872 [NEW]: sprintf() returns trailing NULL character
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-45058@lists.php.net to get a copy of this message
From: kostas at nasis dot com Operating system: Redhat 7.3, 8 PHP version: 4.3.2 PHP Bug Type: Feature/Change Request Bug description: sprintf() returns trailing NULL character 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 bug report at http://bugs.php.net/?id=24872&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=24872&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=24872&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=24872&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=24872&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=24872&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=24872&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=24872&r=support Expected behavior: http://bugs.php.net/fix.php?id=24872&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=24872&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=24872&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=24872&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24872&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=24872&r=dst IIS Stability: http://bugs.php.net/fix.php?id=24872&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=24872&r=gnused

« previous php.bugs (#45058) next »