Posted by Jerry Stuckle on 05/01/07 17:55
Tyno Gendo wrote:
> I have just written a line of code like this (yes, many people think
> this stinks bad):
>
> <?php true == isset($page_seq) ? echo "$page_seq" : false; ?>
>
> However it breaks with 'Unexpected T_ECHO'
>
> But
>
> <?php true == isset($page_seq) ? print "$page_seq" : false; ?>
>
> Works as expected.
>
> Anyone know why? Maybe its blindly obvious to someone, that time of
> the day when the brain SLLLOOOOOOOWWS down.
It fails because the ternary operator requires the true and false
clauses to return values. echo does not return a value. print() does.
It's basically the *very subtle* difference between the two.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|