note 101583 added to function.intval
| From: | yves at osu1 dot php dot net | Date: | Tue, 28 Dec 2010 04:53:37 +0000 |
| Subject: | note 101583 added to function.intval | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-175268@lists.php.net to get a copy of this message | ||
The behaviour of intval() is interesting when supplying a base, and you better check your intval
base-based expressions, as it is counter-intuitive.
As the example shows
<?php
intval('42', 8); // => 34
intval(42, 8); // => 42 !
?>
PHP considers the 42 as being already an integer, and doesn't apply any conversion. And
supplying
<?php
intval(49, 8); // => 49 !
?>
produces no error and no warning.
----
Server IP: 69.147.83.197
Probable Submitter: 110.5.47.62
----
Manual Page -- http://www.php.net/manual/en/function.intval.php
Edit -- https://master.php.net/note/edit/101583
Del: integrated -- https://master.php.net/note/delete/101583/integrated
Del: useless -- https://master.php.net/note/delete/101583/useless
Del: bad code -- https://master.php.net/note/delete/101583/bad+code
Del: spam -- https://master.php.net/note/delete/101583/spam
Del: non-english -- https://master.php.net/note/delete/101583/non-english
Del: in docs -- https://master.php.net/note/delete/101583/in+docs
Del: other reasons-- https://master.php.net/note/delete/101583
Reject -- https://master.php.net/note/reject/101583
Search -- https://master.php.net/manage/user-notes.php