Re: a shortcut to set variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 12, 2011 at 6:34 AM, Richard Quadling <rquadling@xxxxxxxxx>wrote:

> Without running the code, can you say what the output will be in the 3
> examples?
>

Yes, but I would still rewrite that code. ;) I typically reserve the ternary
operator to return a value or assign a variable. Given that it is used less
frequently combined with its precedence in PHP differing from other
languages make using it in complicated expressions prone to errors and
misunderstanding by others.

Adding parentheses avoids interpreter errors but doesn't lessen the
likelihood of another developer breaking the code if they modify it.

David

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux