>>>>> "Miguel" == Miguel Cruz <[EMAIL PROTECTED]> writes:
Miguel> On 13 Jun 2002, Lee Doolan wrote:
>> the arrays below have dates like dateA= array( 0=> "03", 1=>
>> "22", 2=> "02")
>>
>> for 22march2002.
>>
>> why does this work:
>>
>> $retval= ($dateA[2] != $dateB[2]) ? strcmp($dateA[2],
>> $dateB[2]) : (($dateA[0] != $dateB[0]) ? strcmp($dateA[0],
>> $dateB[0]) : (($dateA[1] != $dateB[1]) ? strcmp($dateA[1],
>> $dateB[1]) : 0));
>>
>>
>> but not this:
>>
>> $retval= ($dateA[2] != $dateB[2]) ? strcmp($dateA[2],
>> $dateB[2]) : ($dateA[0] != $dateB[0]) ? strcmp($dateA[0],
>> $dateB[0]) : ($dateA[1] != $dateB[1]) ? strcmp($dateA[1],
>> $dateB[1]) : 0;
Miguel> Why does this:
Miguel> $x = 3 + 5 * 7;
Miguel> produce different results from this:
Miguel> $x = (3 + 5) * 7;
Miguel> ?
Miguel> miguel
The two cases are not the same. In the case above, all operators are
ternary --with equal precedence-- but in your case, the operators are
of different precedence.
As I pointed out to you in e-mail, both of the ternary forms in my
original question would evaluate to the same thing if they were in s C
program. That, admittedly, is no reason why they should evaluate to
he same thing in PHP but it was enough to make me wonder...
--
When the birdcage is open, | donate to causes I care about:
the selfish bird flies away, | http://svcs.affero.net/rm.php?r=leed_25
but the virtuous one stays. |
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php