On 9 Mar 2004 Richard Davey wrote: > $x ? xxx : xxx > > But it makes your code less readable IMHO and offers no tangible > benefit whatsoever.
Ah, to each his/her own I guess ... I actually find: $value = ($condition ? $val1 : $val2); easier to read than: if ($condition) $value = $val1; else $value = $val2; On the other hand for this: $value = ($var1 && ($var2 == 4) && (($var3 == $var7) || ($var9 == "hello"))) ? htmlspecialchars(strstr($string1, $string2) . "test") : NULL; I would prefer to use: if ($var1 && ($var2 == 4) && (($var3 == $var7) || ($var9 == "hello"))) $value = htmlspecialchars(strstr($string1, $string2) . "test"); else $value = NULL; In other words ... IMO you can use the ?: operator to be concise (which increases readability) or to be cryptic (which reduces it). -- Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php