php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15380 Invalid Type Conversion In XOR Operand
Submitted: 2002-02-05 04:54 UTC Modified: 2002-02-27 08:17 UTC
From: jury at elkor dot lv Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.2.0-dev OS: ANY
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: jury at elkor dot lv
New email:
PHP Version: OS:

 

 [2002-02-05 04:54 UTC] jury at elkor dot lv
Invalid Calculation when you make XOR operation between strings like: "12" ^ "9".

It needs to change type from "String" => "Double"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-05 05:38 UTC] yohgaki@php.net
Verified with 4.2.0-dev. (ZE1)
This bug can make nasty bug in script that is really hard to find.

status = Critical


 [2002-02-05 10:52 UTC] sander@php.net
Some results (exactly the same with ZE1 and 2):
echo "12" ^ "9"; // output: nothing
echo "hello"."12" ^ "9"; // output: Q
echo "hello12" ^ "9"; // output: Q
echo "hello".("12" ^ "9"); // output: hell
Yes, that's hell and not hello!
 [2002-02-27 07:49 UTC] derick@php.net
Not critical, assinging to me to check it out.
 [2002-02-27 08:17 UTC] derick@php.net
Actually, it's not a bug, but an undocumented feature.
What hapens is this:

When both operands are strings, the characters in those strings are XORed like this:

result[0] = string1[0] ^ string2[0]
result[1] = string1[1] ^ string2[1]

For your example this is:
result[0] = '1' ^ '9'

which is:
#8 (the backspace character).

I'm fixing the documentation now.

Derick
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 03:01:32 2024 UTC