On Wed, 12 Mar 2003, Andrey Hristov wrote:

>  Few minutes ago I found the following behaviour somehow wierd for me :
> <?php
>     $a = 1;
>     $b = $a==1? 4:$a==2? 5:6;
>     printf("a[%d]b[%d]\n", $a, $b);
> ?>
> Prints : 
> a[1]b[5]
> 
> Similar C program :
> main()
> {
>     int a,b;
>     a = 1;
>     b = a==1? 4:a==2? 5:6;
>     printf("a[%d]b[%d]\n", a, b);
> }
> Prints : 
> a[1]b[4]
> 
> -=-=-=-=-=-
> I think that the behavior of the C program is the right

It's just a different operator precedence; it's not really wrong, just 
different.

Derick

-- 
                                        "my other box is your windows PC"
-------------------------------------------------------------------------
 Derick Rethans                                 http://derickrethans.nl/ 
 PHP Magazine - PHP Magazine for Professionals       http://php-mag.net/
-------------------------------------------------------------------------

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to