Re:Ask HN: PHP Tricks and Best Practices?
by DanHulton on Wednesday October 29, 2008 @02:41PM
(#347807)
I've had trouble for a while now with chained ifs, as in:
This gets messy if there's anything interesting in those chunks. Instead, take advantage of short-circuiting and put those chunks in functions. Then you can rewrite the above as:
Also, use the ternary operator EVERYWHERE YOU CAN - you'll clean up so much code with it.
[ Parent
| on HN ]
Re:Ask HN: PHP Tricks and Best Practices?
by nuclear_eclipse on Wednesday October 29, 2008 @03:25PM
(#347867)
even better is:
$success =
do_chunk_a() &&
do_chunk_b() &&
do_chunk_c();
...