RE: [PHP] isset()

From: Date: Sun, 25 Feb 2001 10:27:24 +0000
Subject: RE: [PHP] isset()
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-41576@lists.php.net to get a copy of this message
100% agreed! this makes much more sense then any of us was saying before. Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) maxim@phpbeginner.com www.phpbeginner.com -----Original Message----- From: Mark Maggelet [mailto:maggelet@mminternet.com] Sent: Sunday, February 25, 2001 5:01 PM To: creinig@mayn.de; php-general@lists.php.net Subject: Re: [PHP] isset() On Sat, 24 Feb 2001 17:51:07 +0100, Christian Reiniger (creinig@mayn.de) wrote: >On Saturday 24 February 2001 17:18, PHPBeginner.com wrote: >> in my preceding email I've written: >> >> if($var!='') >> >> will fix your all your worries without an intervention of a strings >> function. > >Except that it will throw a warning in PHP4 if $var is not set. >=> isset () should be used. man, this is like the thread that will not die. isset() will return true for an empty string, which is not what he wants. the right thing to do is use if((isset($var))&&($var!="")) the isset on the left gets evaluated first so a warning is never thrown. to be even safer, you can go: if((isset($var))&&(trim($var)!="")) you do not want to use strlen() for the following reasons: 1) makes code unreadable -> very sloppy 2) overhead 3) it will give a warning when $var is not set (error_reporting 15 only). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#41576) next »