PHP 4.0 Bug #7878: intval base argument useless unless first arg is a string
| From: | zak@php.net | Date: | Sun, 19 Nov 2000 05:55:06 +0000 |
| Subject: | PHP 4.0 Bug #7878: intval base argument useless unless first arg is a string | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-38493@lists.php.net to get a copy of this message | ||
From: zak@php.net
Operating system: Win32 and Linux
PHP version: 4.0.3pl1
PHP Bug Type: Documentation problem
Bug description: intval base argument useless unless first arg is a string
The base argument for intval has no effect unless the first argument is a string.
I am not sure what the best fix for this is:
We could document that you should make the first argument a string to have the base argument used.
We could convert the first argument to a string (using convert_to_string_ex) if there is a second
argument
That would mke calls made with base 10 would work as expected:
intval (1000, 11); // Returns 1331
intval ('1000', 11); // Returns 1331
However, calls using other bases might seem a bit odd:
intval ('077', 8); // returns 63
intval (077, 8); // returns 51
This would be because 077 is converted to 63, then the argument is converted to a string.
Or we could add a warning if the first arg is not a string?
Any thoughts??
--
Edit Bug report at: http://bugs.php.net/?id=7878&edit=1