[PHP-DEV] PHP 4.0 Bug #8348 Updated: $val = TRUE AND FALSE; // Will always give TRUE !! From: stas <email protected>
Date: 12/21/00

ID: 8348
Updated by: stas
Reported By: samuel.blume <email protected>
Old-Status: Open
Status: Closed
Bug Type: Scripting Engine problem
Assigned To:
Comments:

>From Adam Trachtenberg <adam <email protected>>:

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 <email protected>
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 <email protected>
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

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>