note 104810 added to function.settype
| From: | SaraSmith at osu1 dot php dot net | Date: | Fri, 08 Jul 2011 13:37:46 +0000 |
| Subject: | note 104810 added to function.settype | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-181350@lists.php.net to get a copy of this message | ||
"Use intval instead of settype for integers. Much more reliable."
While 'intval' is more reliable than 'settype', it is still a PHP function.
Functions are significantly slower than raw native conversions. If you need an integer, use a
typecast: (int)$someval; Typecasting is baked into the core Zend engine, which is as close to the
hardware as you can get in PHP. Everyone should consider intval() and settype() as legacy functions
that new code should not use since there are better alternatives in most cases with the sole
exception of base conversions where base 10 is not being used in the case of intval().
----
Server IP: 69.147.83.197
Probable Submitter: 174.18.27.120
----
Manual Page -- http://www.php.net/manual/en/function.settype.php
Edit -- https://master.php.net/note/edit/104810
Del: integrated -- https://master.php.net/note/delete/104810/integrated
Del: useless -- https://master.php.net/note/delete/104810/useless
Del: bad code -- https://master.php.net/note/delete/104810/bad+code
Del: spam -- https://master.php.net/note/delete/104810/spam
Del: non-english -- https://master.php.net/note/delete/104810/non-english
Del: in docs -- https://master.php.net/note/delete/104810/in+docs
Del: other reasons-- https://master.php.net/note/delete/104810
Reject -- https://master.php.net/note/reject/104810
Search -- https://master.php.net/manage/user-notes.php