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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: laurent_tourreau at ifrance dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed May 07 08:01:27 2025 UTC