note 55390 deleted from function.is-int by nlopess
| From: | nlopess@php.net | Date: | Tue, 02 Aug 2005 11:00:25 +0000 |
| Subject: | note 55390 deleted from function.is-int by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-92943@lists.php.net to get a copy of this message | ||
Note Submitter: fanfatal at fanfatal dot pl
Reason: useless
----
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 ;-)
...