You are here: Re: shortif (tertiary) fails with echo but not print ? « PHP Programming Language « IT news, forums, messages
Re: shortif (tertiary) fails with echo but not print ?

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация