note 86615 modified in function.isset by felipe

From: Date: Mon, 27 Oct 2008 11:51:52 +0000
Subject: note 86615 modified in function.isset by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-145799@lists.php.net to get a copy of this message
Here's a simple function to test if the variable is set: <?php function is($var) { if (!isset($var)) return false; if ($var!==false) return true; return false; } ?> Now instead of very popular (but invalid in many situations): if (!$var) $var=5; you can write: if (!is($var)) $var=5; --was-- Here's a simple function to test if the variable is set: function is($var) { if (!isset($var)) return false; if ($var!==false) return true; return false; } Now instead of very popular (but invalid in many situations): if (!$var) $var=5; you can write: if (!is($var)) $var=5; http://php.net/manual/en/function.isset.php

« previous php.notes (#145799) next »