note 110316 deleted from control-structures.if by googleguy
| From: | googleguy@php.net | Date: | Wed, 10 Oct 2012 20:36:57 +0000 |
| Subject: | note 110316 deleted from control-structures.if by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191244@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymouse
----
To marcin
A much simpler way to refactor your example
if ( is_object($times)){
if ((float)$times->getTime()>0){ A } else { B } else { B }
is to note that && is short circuit. See http://www.php.net/manual/en/language.operators.logical.php
Why not write it as
if (is_object(...) && blah > 0) { A } else { B }
??
There's no need for the conditional operator.