Image

Imagesoltice wrote in Imagephp

Oh sure, now I wish I had that operator

There's a shortcut operator in C++ to the traditional if...else block. If I recall it goes someting like this:

[condition] ? [true statement] : [false statement]


I never liked this operator in C. It was too elegant for it's own good, IMHO. When coding PHP, however, I've often wished for just such an operator for a particular situation. Say, for example, you have to change the rowspan of a table:

<?= $row["thing"] == "yes" ? "4" : "2" ?>


Which would otherwise be

<? if($row["thing"] == "yes"){ ?>4<? }else{ ?>2<? } ?>


update: Nevermind all, appearently it was a bit further buried in the manual than I expected: http://www.php.net/manual/en/language.expressions.php

Sorry!!!