note 58054 deleted from function.isset by jome

From: Date: Sun, 23 Oct 2005 09:00:40 +0000
Subject: note 58054 deleted from function.isset by jome
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-97437@lists.php.net to get a copy of this message
Note Submitter: ifyouwantblood.de Reason: bad code ---- i worked on a calculator so the user-input could be zero -> couldn´t use !empty() cause it returns FALSE on those. but i was also too lazy to write: if(isset($_GET['var']) && $_GET['var']!='') so i wrote this function: function cuv($varname,$postget=1) { if($postget) { if(isset($_POST[$varname]) && $_POST[$varname]!='') return (bool) 1; else return (bool) 0; } else { if(isset($_GET[$varname]) && $_GET[$varname]!='') return (bool) 1; else return (bool) 0; } } so to check GET vars i only have to write: if(cuv($varname,0)) and for post vars only: if(cuv($varname))

« previous php.notes (#97437) next »