note 33179 deleted from function.is-int by danbrown

From: Date: Thu, 28 Oct 2010 04:49:31 +0000
Subject: note 33179 deleted from function.is-int by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-173541@lists.php.net to get a copy of this message
Note Submitter: mark at g33kz dot co dot uk ---- Or you could just use is_numeric() I have a file called input.php which I run at the beginning of all my scripts which makes sure all my input numbers are converted to integers automatically. if ($_GET) { foreach ($_GET as $k => $v) { $_GET[$k] = trim (stripslashes ($v)); if (is_numeric ($v)) { $_GET[$k] = intval ($v); } } } if ($_POST) { foreach ($_POST as $k => $v) { $_POST[$k] = trim (stripslashes ($v)); if (is_numeric ($v)) { $_POST[$k] = intval ($v); } } } if ($_COOKIE) { foreach ($_COOKIE as $k => $v) { $_COOKIE[$k] = trim (stripslashes ($v)); if (is_numeric ($v)) { $_COOKIE[$k] = intval ($v); } } }

« previous php.notes (#173541) next »