Re[2]: [PHP] PHP newbie question

From: Date: Wed, 10 Jan 2001 19:12:56 +0000
Subject: Re[2]: [PHP] PHP newbie question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-33746@lists.php.net to get a copy of this message
Hello Neil, Wednesday, January 10, 2001, 10:33:09 AM, you wrote: >> : <?php if (! $a) print "Hello, World!"; // script 2 ?> >> >> $a evaluates to false, the ! reverses it, and it prints "Hello, World!" NZ> What is bothering me is the following: if variables that are not assigned NZ> a value were to evaluate to false then since false is the same as the NZ> number 1 the following PHP script should print the number 1 but instead NZ> prints nothing: NZ> <?php if (! $a) print $a; ?> NZ> How is this behavior justified? The operation (! $a) must return something .. true or false. The only other option would be to crash the system to a debugger with a nasty message about the developer should have checked the variable cause it wasn't assigned. For this reason if you are unsure about the state try If (isset($a) { If (! $a) { } Else { } } Something like this always works. -- DSig ````` David Tod Sigafoos ( O O ) mailto:dsig@teleport.com _______oOOo__( )__oOOo_______ Using 'The Bat' 1.48f

« previous php.general (#33746) next »