Re: PHP 4.0 Bug #8348 Updated: $val = TRUE AND FALSE; // Will always give TRUE !!

From: Date: Thu, 21 Dec 2000 15:17:16 +0000
Subject: Re: PHP 4.0 Bug #8348 Updated: $val = TRUE AND FALSE; // Will always give TRUE !!
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-42049@lists.php.net to get a copy of this message
You should read this page in the manual about Operator Precedence. http://www.php.net/manual/language.operators.precedence.php AND has a lower precedence than =, so $val = TRUE AND FALSE is the same as ($val = TRUE) and FALSE. Also, you want && (logical and) instead of & (bitwise and) in your later example. (Although, & does have an even tighter binding than &&, so that "works," too.) -adam On 21 Dec 2000 samuel.blume@infeer.com wrote: > ID: 8348 > User Update by: samuel.blume@infeer.com > Status: Open > Bug Type: Scripting Engine problem > Description: $val = TRUE AND FALSE; // Will always give TRUE !! > > Ups... a little typo above // bool(false) should be // bool(true) > > > $val = TRUE AND FALSE; //Will always give TRUE !! > var_dump($val); // = bool(true) > > using () or & will have the right effect > $val = (TRUE AND FALSE); > var_dump($val); // = int(0) > > $val = TRUE & FALSE; > var_dump($val); // = int(0) > > > Previous Comments: > --------------------------------------------------------------------------- > > [2000-12-21 06:57:03] samuel.blume@infeer.com > Folling is unusual: > > $val = TRUE AND FALSE; //Will always give TRUE !! > var_dump($val); // = bool(false) > > using () will have the right effect > $val = (TRUE AND FALSE); > var_dump($val); // = int(0) > > > --------------------------------------------------------------------------- > > > Full Bug description available at: http://bugs.php.net/?id=8348 > > > -- / adam maccabee trachtenberg | visit college life online \ \ adam@student.net | http://www.student.com /

« previous php.dev (#42049) next »