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

From: Date: Thu, 21 Dec 2000 15:21:14 +0000
Subject: PHP 4.0 Bug #8348 Updated: $val = TRUE AND FALSE; // Will always give TRUE !!
Groups: php.dev 
Request: Send a blank email to php-dev+get-42050@lists.php.net to get a copy of this message
ID: 8348 Updated by: stas Reported By: samuel.blume@infeer.com Old-Status: Open Status: Closed Bug Type: Scripting Engine problem Assigned To: Comments: From Adam Trachtenberg <adam@student.net>: 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 Previous Comments: --------------------------------------------------------------------------- [2000-12-21 07:20:48] samuel.blume@infeer.com 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) --------------------------------------------------------------------------- [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

« previous php.dev (#42050) next »