Bug #53989 [Opn->Bgs]: Notice: Undefined variable/index with xor, but not with or
| From: | felipe@php.net | Date: | Fri, 11 Feb 2011 21:21:18 +0000 |
| Subject: | Bug #53989 [Opn->Bgs]: Notice: Undefined variable/index with xor, but not with or | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-158714@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53989&edit=1
ID: 53989
Updated by: felipe@php.net
Reported by: martin at feredoras dot de
Summary: Notice: Undefined variable/index with xor, but not
with or
-Status: Open
+Status: Bogus
Type: Bug
Package: Scripting Engine problem
Operating System: Tested only with Windows
PHP Version: 5.3.5
Block user comment: N
Private report: N
New Comment:
This is because the OR logical expression doesn't requires the right
expression to be executed when the first expression is evaluated to
true. But XOR requires.
Previous Comments:
------------------------------------------------------------------------
[2011-02-11 03:18:08] martin at feredoras dot de
Description:
------------
I want to check, if a variable is not set. If the variable is not set, i
want to
check, if this variable has a special value. There is no problem with
"or", but
with "xor" outputs a notice.
Test script:
---------------
<?
session_start();
if(!isset($_SESSION['foo']) xor $_SESSION['foo'] == 1) echo "foo";
if(!isset($bar) xor $bar== 1) echo "bar";
if(!isset($_SESSION['foo']) or $_SESSION['foo'] == 1) echo "foo";
if(!isset($bar) or $bar== 1) echo "bar";
?>
Expected result:
----------------
foobarfoobar
Actual result:
--------------
Notice: Undefined index: foo in C:\xampp\htdocs\feredoras\testing.php on
line 4
foo
Notice: Undefined variable: bar in C:\xampp\htdocs\feredoras\testing.php
on line 5
barfoobar
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53989&edit=1