php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47004 Erratic short conditionals
Submitted: 2009-01-05 01:02 UTC Modified: 2009-01-05 21:01 UTC
From: am at webhike dot de Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.8 OS: XAMPP 1.6.8
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: am at webhike dot de
New email:
PHP Version: OS:

 

 [2009-01-05 01:02 UTC] am at webhike dot de
Description:
------------
Using Short Conditionals with more lines is causing wrong results:

Reproduce code:
---------------
   $x = 7;

   echo 
      $x == 5 ? 'five' : 
      $x == 6 ? 'six' : 
      $x == 7 ? 'seven' : 
      $x == 8 ? 'eight' : 
      $x == 9 ? 'nine' : 
      null;  

Actual result:
--------------
Returns 'nine'. Multiline Short Conditionals fail.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-05 11:10 UTC] jani@php.net
It's the operator presedence. For more info:
http://www.php.net/manual/en/language.operators.precedence.php
 [2009-01-05 21:01 UTC] am at webhike dot de
Does it make sense to use such confusing left-to-right presence, while other program languages like Java and C operate from right-to-left?
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 12:01:33 2025 UTC