note 103696 added to function.filter-var

From: Date: Thu, 28 Apr 2011 16:43:49 +0000
Subject: note 103696 added to function.filter-var
Groups: php.notes 
Request: Send a blank email to php-notes+get-179239@lists.php.net to get a copy of this message
<?php /** * Fast filter_var * Yousef Ismaeil - cliprz@gmail.com */ function fi1ter($value,$type) { switch ($type) { case 'INT': case 'INTGER': $result = filter_var($value,FILTER_VALIDATE_INT); break; case 'FLOAT': case 'DOUBLE': $result = filter_var($value,FILTER_VALIDATE_FLOAT); break; case 'BOOLEAN': case 'BOOL': $result = filter_var($value,FILTER_VALIDATE_BOOLEAN); break; case 'EMAIL': $result = filter_var($value,FILTER_VALIDATE_EMAIL); break; case 'URL': $result = filter_var($value,FILTER_VALIDATE_URL); break; default: $result = $value; } return $result; } // used // email if (!fi1ter('cliprz@gmail.com','EMAIL')) echo 'not email<br />'; // true // urls if (!fi1ter('http://www.php.net','URL')) echo 'not url<br />'; // true // others // intger fi1ter(1,'INT'); // true // float fi1ter(1.5,'FLOAT'); // true fi1ter(6.5,'DOUBLE'); // true // boolean fi1ter(false,'BOOLEAN'); // true fi1ter(true,'BOOL'); // true ?> ---- Server IP: 69.147.83.197 Probable Submitter: 178.53.64.180 ---- Manual Page -- http://www.php.net/manual/en/function.filter-var.php Edit -- https://master.php.net/note/edit/103696 Del: integrated -- https://master.php.net/note/delete/103696/integrated Del: useless -- https://master.php.net/note/delete/103696/useless Del: bad code -- https://master.php.net/note/delete/103696/bad+code Del: spam -- https://master.php.net/note/delete/103696/spam Del: non-english -- https://master.php.net/note/delete/103696/non-english Del: in docs -- https://master.php.net/note/delete/103696/in+docs Del: other reasons-- https://master.php.net/note/delete/103696 Reject -- https://master.php.net/note/reject/103696 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#179239) next »