php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10332 XOR logical doesnt work properly
Submitted: 2001-04-15 05:39 UTC Modified: 2001-04-28 19:33 UTC
From: laurent_tourreau at ifrance dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.0.4pl1 OS: Slackware 7.1 Linux 2.2.16
Private report: No CVE-ID: None
 [2001-04-15 05:39 UTC] laurent_tourreau at ifrance dot com
<?php
	$h = 4; $i =5, $j=6;
	if ($h == 4 xor $i == 5 xor $j == 6) {
	echo ("The condition is true");
	}
	else {
	echo ("The condition is false");
	}
?>

When i run it, i obtain The condition is true...
Im running PHP as Apache module.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-04-28 19:32 UTC] elixer@php.net
The "==" has higher precedence than does "xor," so evaluating left to right we have:

$h == 4 xor $i == 5 xor $j == 6
  or:
true xor true xor true
  then:
false xor true
  and finally:
true
  which is true, which is expected behavior.  Use parens to group the exressions to get the results you are looking for.

Sean
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 07:01:27 2024 UTC