Re: bug

From: Date: Fri, 01 Jul 2011 00:34:02 +0000
Subject: Re: bug
References: 1  Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-11409@lists.php.net to get a copy of this message
On 30 June 2011 21:55, Rere Rere <rere_batta@yahoo.com> wrote: > <?php >  $x=0; > if($x=='ok')echo "ok";  //ok  (why???????) > echo $x;//0 (still have the original value) > > ?> Because PHP uses type juggling when comparing values. See http://docs.php.net/manual/en/language.types.type-juggling.php Your test will work better if you use ... if($x==='ok') This will compare the value AND the type. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

« previous php.webmaster (#11409) next »