| 
 Posted by Janwillem Borleffs on 12/06/07 15:24 
newbie schreef: 
> Can someone explain to me why the following code yields output "20 < x  
> <= 30"? 
>  
> echo $x > 30 ? "x > 30" : $x > 20 ? "20 < x <= 30" : "x < 20"; 
>  
>  
> I expected that ir will be evaluated as ($x > 30 ? "x > 30" : ($x > 20 ?  
> "20 < x <= 30" : "x < 20")) but I was wrong. 
 
It is evaluated from left to right: 
 
If x > 30 
    print 'x > 30' 
Else 
   If x > 20 
      print '20 < x <= 30' 
   Else 
      print 'x < 20' 
   End If 
End If 
 
 
JW
 
  
Navigation:
[Reply to this message] 
 |