note 98767 added to function.isset

From: Date: Tue, 06 Jul 2010 11:10:11 +0000
Subject: note 98767 added to function.isset
Groups: php.notes 
Request: Send a blank email to php-notes+get-170730@lists.php.net to get a copy of this message
Keep that an empty string is not null, and an empty GET or POST field returns an empty string instead of NULL, thus... file.php?foo <?php $a = ''; $b = NULL; isset($a); // => TRUE isset($b); // => FALSE isset($_GET['foo']); // => TRUE ?> With that in mind, one probably would use isset() to check if a variable has been declared somehow and it's value is not the special value NULL. If you want to check if the value is an empty string, it's probably a better idea to check it literally: <?php (isset($a) && $a == '') // => TRUE ?> ---- Server IP: 69.147.83.197 Probable Submitter: 189.26.239.249 ---- Manual Page -- http://www.php.net/manual/en/function.isset.php Edit -- https://master.php.net/note/edit/98767 Del: integrated -- https://master.php.net/note/delete/98767/integrated Del: useless -- https://master.php.net/note/delete/98767/useless Del: bad code -- https://master.php.net/note/delete/98767/bad+code Del: spam -- https://master.php.net/note/delete/98767/spam Del: non-english -- https://master.php.net/note/delete/98767/non-english Del: in docs -- https://master.php.net/note/delete/98767/in+docs Del: other reasons-- https://master.php.net/note/delete/98767 Reject -- https://master.php.net/note/reject/98767 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#170730) next »