|
Posted by Bert Melis on 05/10/05 23:02
juglesh wrote:
> "$string = isset($xyz) ? $xyz : "something else";"
>
>
> Hello, someone gave code like this in another thread. I understand (by
>
> inference) what it does, but have not found any documentation on this
> type of syntax.
>
>
> Any one have links to this shortuct(?) syntax and other types of
> syntax?
>
>
> thanks
> j
>
Look here:
http://www.php.net/manual/en/language.expressions.php
and search for "ternary conditional operator"
$first ? $second : $third
$first is evaluated, and if true, $second is the result. otherwise
$third is the result.
To store the result in a var:
$result = ($first) ? $second : $third
Navigation:
[Reply to this message]
|