by hackaflocka · 10y ago · 0 comments
if False and (fibonacci(1000)/fibonacci(1000)):
print "Nope"
It will immediately evaluate to False and pring "Nope" rather than checking the (fibonacci(1000)/fibonacci(1000)) portion of the conditional.EDIT: Side note, is there a shortcut for displaying code snippets within HN posts? Extra returns (what I usually use for clarification by formatting) do not display very well.
Indent your code snippets with a minimum of four spaces and they will be rendered as preformatted, monospaced text. Vertically adjacent lines thus indented will be rendered as a single block.
(if isset($foo) && $foo == 14)
If $foo is not set the second boolean expression is not evaluated (short circuit evaluation).
In fact, checking if isset followed by another boolean expression is very idiomatic in PHP.