note 91649 added to function.intval
| From: | spoon_reloaded at gmail dot com | Date: | Sun, 21 Jun 2009 17:35:32 +0000 |
| Subject: | note 91649 added to function.intval | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-157198@lists.php.net to get a copy of this message | ||
Here is a really useful undocumented feature:
You can have it automatically deduce the base of the number from the prefix of the string using the
same syntax as integer literals in PHP ("0x" for hexadecimal, "0" for octal,
non-"0" for decimal) by passing a base of 0 to intval():
echo intval("0x1a", 0), "\n"; // hex; prints "26"
echo intval("057", 0), "\n"; // octal; prints "47"
echo intval("42", 0), "\n"; // decimal; prints "42"
----
Server IP: 64.71.164.2
Probable Submitter: 76.91.63.71
----
Manual Page -- http://www.php.net/manual/en/function.intval.php
Edit -- https://master.php.net/note/edit/91649
Del: integrated -- https://master.php.net/note/delete/91649/integrated
Del: useless -- https://master.php.net/note/delete/91649/useless
Del: bad code -- https://master.php.net/note/delete/91649/bad+code
Del: spam -- https://master.php.net/note/delete/91649/spam
Del: non-english -- https://master.php.net/note/delete/91649/non-english
Del: in docs -- https://master.php.net/note/delete/91649/in+docs
Del: other reasons-- https://master.php.net/note/delete/91649
Reject -- https://master.php.net/note/reject/91649
Search -- https://master.php.net/manage/user-notes.php