php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44252 ? : evaluation bug
Submitted: 2008-02-26 12:35 UTC Modified: 2008-02-26 12:57 UTC
From: OlafvdSpek at GMail dot Com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.2.5 OS: Linux, Windows
Private report: No CVE-ID: None
 [2008-02-26 12:35 UTC] OlafvdSpek at GMail dot Com
Description:
------------
The following code echoes 3 while it should echo 2.
It should be evaluated as 1 ? 2 : (0 ? 3 : 4). I've no idea how PHP comes up with 3.

Reproduce code:
---------------
echo 1 ? 2 : 0 ? 3 : 4;

Expected result:
----------------
2

Actual result:
--------------
3

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-26 12:47 UTC] felipe@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

This is documented.
See the example#3:
http://docs.php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary
 [2008-02-26 12:57 UTC] OlafvdSpek at GMail dot Com
Ah, so it's evaluated as (1 ? 2 : 0) ? 3 : 4
Nice, very nice. :(
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 01 07:01:30 2024 UTC