php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63088 <> operator matches different on CLI -r vs. CLI -f
Submitted: 2012-09-14 09:10 UTC Modified: 2012-09-14 09:53 UTC
From: daniel dot rudolf at eifel-online dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3.17 OS: Windows XP
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: daniel dot rudolf at eifel-online dot com
New email:
PHP Version: OS:

 

 [2012-09-14 09:10 UTC] daniel dot rudolf at eifel-online dot com
Description:
------------
The <> operator matches different when passing code directly to CLI mode using the -r parameter vs. a file using the -f parameter.

Test script:
---------------
php.exe -r "error_reporting(0); $a = array('parent' => array('existing' => '0')); var_dump($a['notExisting'] <> "0"); var_dump($a['notExisting'] <> $a['parent']['existing']);"

---
vs.
---

php.exe -f test.php
with test.php has the contents:
<?php error_reporting(0); $a = array('parent' => array('existing' => '0')); var_dump($a['notExisting'] <> "0"); var_dump($a['notExisting'] <> $a['parent']['existing']); ?>

Expected result:
----------------
bool(true)
bool(true)

---
vs.
---

bool(false)
bool(true)

Actual result:
--------------
bool(false)
bool(true)

---
vs.
---

bool(false)
bool(true)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-09-14 09:12 UTC] daniel dot rudolf at eifel-online dot com
Damn... Sorry, I copied the results wrong...

Expected result:
----------------
bool(true)
bool(true)

---
vs.
---

bool(true)
bool(true)

Actual result:
--------------
bool(false)
bool(true)

---
vs.
---

bool(true)
bool(true)
 [2012-09-14 09:42 UTC] laruence@php.net
-Status: Open +Status: Not a bug
 [2012-09-14 09:42 UTC] laruence@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

in cmd, you should write two quotes(escape) in the quote string:

php.exe -r "var_dump(NULL <> "0");" 

should be:

php.exe -r "var_dump(NULL <> ""0"");"

otherwise, I guess CMD will take it as:
php.exe -r "var_dump(NULL <> 0);"
 [2012-09-14 09:53 UTC] laruence@php.net
or:
php.exe -r "var_dump(NULL <> '0');"
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed May 07 01:01:28 2025 UTC