Re: damned "false"

From: Date: Sat, 20 Jul 2002 09:11:39 +0000
Subject: Re: damned "false"
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-108636@lists.php.net to get a copy of this message
Hi, This is working exactly the way it has to ... What is wrong with it?. In the first assignment in the 'if' is evaluating to string and it is a true so the "OK" is printed. In the second "if", you are assigning a true value which is evaluated as true and it prints "OK". In the third "if" statment, you are assigning a 'false' and it evaluates to false to the if statment so that it is not printing the "OK". try this also for better understanding.... if($a=0) { echo "I never be printed"; } if(!$a=0) { echo "I will be printed, if you run me." } i hope i understand your question.... Sukumar. > I am not very happy how generaly boolean comparison is solved in > PHP...but I checked different stuff and like this shouldn't be: > ---- > <? > $a="null"; > if ($a="dwa") { // one sign = so it is OK > echo "OK"; > } > if ($a=true) { > echo "OK"; > } > if ($a=false) { > echo "OK"; //but it is not written!!!!!!! > } > ?> > I tested it in PHP4.2.0 (LINUX) >

« previous php.general (#108636) next »