note 55312 added to function.is-numeric
| From: | maninblack00atmaildotru at osu1 dot php dot net | Date: | Fri, 29 Jul 2005 23:23:11 +0000 |
| Subject: | note 55312 added to function.is-numeric | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-92744@lists.php.net to get a copy of this message | ||
blazatek at wp dot pl wrote a function to check POST inputs for ASCII-keys or smth like that. there
was an error while filtering $varvalue (it was only the value of the last filter
'addslashes')
here's the corrected function:
<?
function is_num ($num) {
// .....
}
function test_post($tab) {
$post = array();
$post = $tab;
foreach ($post as $varname => $varvalue) {
echo $tab[$varname];
if (empty($varvalue)) {
$post[$varname] = null;
}
elseif (is_num($varvalue)) {
$varvalue=trim($varvalue);
$varvalue=strip_tags($varvalue);
$varvalue=intval($varvalue);
$post[$varname]=addslashes($varvalue);
}
else {
$post[$varname]=NULL;
}
}//forech
return $post;
}
?>
hope that correction is correct ;)
----
Submitter IP: 195.54.192.44
----
Manual Page -- http://www.php.net/manual/en/function.is-numeric.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55312
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55312&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55312&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55312&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55312&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55312&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55312&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55312&report=yes
Search -- http://master.php.net/manage/user-notes.php