|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-07-30 11:40 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 08 09:00:01 2025 UTC |
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.