#47004 [Bgs]: Erratic short conditionals

From: Date: Mon, 05 Jan 2009 21:01:33 +0000
Subject: #47004 [Bgs]: Erratic short conditionals
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-132574@lists.php.net to get a copy of this message
 ID:               47004
 User updated by:  am at webhike dot de
 Reported By:      am at webhike dot de
 Status:           Bogus
 Bug Type:         Scripting Engine problem
 Operating System: XAMPP 1.6.8
 PHP Version:      5.2.8
 New Comment:

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?


Previous Comments:
------------------------------------------------------------------------

[2009-01-05 11:10:34] jani@php.net

It's the operator presedence. For more info:
http://www.php.net/manual/en/language.operators.precedence.php

------------------------------------------------------------------------

[2009-01-05 01:02:00] 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.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=47004&edit=1



Thread (3 messages)

« previous php.bugs (#132574) next »