note 99161 added to function.intval

From: Date: Sat, 31 Jul 2010 01:16:29 +0000
Subject: note 99161 added to function.intval
Groups: php.notes 
Request: Send a blank email to php-notes+get-171279@lists.php.net to get a copy of this message
This documentation is misleading. The actual default value for the $base parameter is 0, not 10. When you pass $base=0 (or don't specify it), the function will "guess" the base from the contents of the given string, emulating C: if the string starts with "0x", the used base will be 16, if the string starts with "0", the used base will be 8, otherwise the used base will be 10. So, pass $base=10 explicitly if you want to force any leading zeroes to be ignored (and prevent them from triggering base 8). Examples: <?php intval("010"); // 8 intval("010", 0); // 8 intval("010", 10); // 10 ?> ---- Server IP: 69.147.83.197 Probable Submitter: 201.87.81.8 ---- Manual Page -- http://www.php.net/manual/en/function.intval.php Edit -- https://master.php.net/note/edit/99161 Del: integrated -- https://master.php.net/note/delete/99161/integrated Del: useless -- https://master.php.net/note/delete/99161/useless Del: bad code -- https://master.php.net/note/delete/99161/bad+code Del: spam -- https://master.php.net/note/delete/99161/spam Del: non-english -- https://master.php.net/note/delete/99161/non-english Del: in docs -- https://master.php.net/note/delete/99161/in+docs Del: other reasons-- https://master.php.net/note/delete/99161 Reject -- https://master.php.net/note/reject/99161 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#171279) next »