PHP 4.0 Bug #8803 Updated: crazy implementation of printf/sprintf
| From: | derick@php.net | Date: | Fri, 19 Jan 2001 15:10:38 +0000 |
| Subject: | PHP 4.0 Bug #8803 Updated: crazy implementation of printf/sprintf | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-44562@lists.php.net to get a copy of this message | ||
ID: 8803
Updated by: derick
Reported By: mikeb@gbdirect.co.uk
Old-Status: Open
Status: Closed
Bug Type: Unknown/Other Function
Assigned To:
Comments:
This works fine:
echo sprintf ("%2x", 29);
output:
1d
This is not a bug.
Previous Comments:
---------------------------------------------------------------------------
[2001-01-19 10:07:24] mikeb@gbdirect.co.uk
Whether a bug or a feature, I consider it a serious bug that printf/sprintf
do not fully adhere to the formatting rules set out in ANSI/ISO C documentation. In particular, I
have just wasted the better part of a day discovering that code which used %.2x to format a 2-digit
hex number
(worked fine in php3) now just prints nothing using 4.04pl1
Surely the formatting is done using the underlying sprintf function anyhow? If not, then php really
should not call this function sprintf() but something that indicates that is not the same.
Just my opinion, but it has been very frustrating and seems an unneccessary difference.
Mike Banahan
Sample code:
<?
printf(":%.2x:n", 14);
?>
Sample output:
X-Powered-By: PHP/4.0.4pl1
Content-type: text/html
::
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=8803