note 35621 added to function.isset
| From: | flobee at gmx dot net | Date: | Mon, 08 Sep 2003 18:16:20 +0000 |
| Subject: | note 35621 added to function.isset | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-55857@lists.php.net to get a copy of this message | ||
just as note: if you want to check variables by boolean value: true or false , "isset" has
a different meaning!
<?php
$var=null;
// sample 1
if($var) {
// if true or another value exept "false" , "null": go on here
echo "1. var is true or has a value $var<br>";
} else {
echo "1. var is "false" or "null"<br>";
}
if(!$var) {
// if false or "null": go on here
echo "2. var has no value $var<br>";
} else {
echo "2. var is "false" or "null"<br>";
}
// sample 2
$var =false;
if(isset($var)) {
// $var is false so it is set to a value and the execution goes here
echo "3. var has value: $var<br>";
}
$var=null;
if(!isset($var)) {
// $var is null (does not exist at this time) and the execution goes here
echo "4. var was not set $var<br>";
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.isset.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35621
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35621&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35621&report=yes