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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

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-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC