note 110316 added to control-structures.if

From: Date: Wed, 10 Oct 2012 11:26:24 +0000
Subject: note 110316 added to control-structures.if
Groups: php.notes 
Request: Send a blank email to php-notes+get-191230@lists.php.net to get a copy of this message
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. ---- Server IP: 69.147.83.199 Probable Submitter: 27.99.20.143 ---- Manual Page -- http://www.php.net/manual/en/control-structures.if.php Edit -- https://master.php.net/note/edit/110316 Del: integrated -- https://master.php.net/note/delete/110316/integrated Del: useless -- https://master.php.net/note/delete/110316/useless Del: bad code -- https://master.php.net/note/delete/110316/bad+code Del: spam -- https://master.php.net/note/delete/110316/spam Del: non-english -- https://master.php.net/note/delete/110316/non-english Del: in docs -- https://master.php.net/note/delete/110316/in+docs Del: other reasons-- https://master.php.net/note/delete/110316 Reject -- https://master.php.net/note/reject/110316 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#191230) next »