note 55390 added to function.is-int
| From: | fanfatal at fanfatal dot pl | Date: | Tue, 02 Aug 2005 06:31:02 +0000 |
| Subject: | note 55390 added to function.is-int | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-92926@lists.php.net to get a copy of this message | ||
I wrote some usefull function again :D
If you want to check if your data from _POST or _GET is int you can't use normal function
is_int() beacuse external datas are always as strings ;]
For this you can use that:
<?php
/*
* Find whether a variable is only with digits
*
* @author FanFataL
* @param mixed
* @return bool
*/
function isint($mixed) {
return (bool)preg_match('/^[\d]+$/', $mixed);
}
// Example:
is_int($_POST['age']); // Always false
isint($_POST['age']); // true when it is a number ;]
?>
Greatings ;-)
...
----
Manual Page -- http://www.php.net/manual/en/function.is-int.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55390
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55390&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55390&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55390&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55390&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55390&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55390&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55390&report=yes
Search -- http://master.php.net/manage/user-notes.php