note 43969 deleted from language.control-structures by aidan
| From: | aidan@php.net | Date: | Thu, 07 Oct 2004 13:50:54 +0000 |
| Subject: | note 43969 deleted from language.control-structures by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-78126@lists.php.net to get a copy of this message | ||
Note Submitter: andreas dot kurtz at urz dot uni-heidelberg dot de
----
Yes, it's correct, that the order doesn't matter. But in the case of switching the
parameters of comparison, mainly in complex expressions easy comprehensibility is no longer assured.
<?php
if(100 < $age) {}
if($age > 100) {} // much easier to retrace
// and even in possible problems of assignment
if(MONDAY == $weekday) {}
// is the following use obviously more understandable
if($weekday == MONDAY) {}
// even in simple examples - so imagine a more complicated one
?>
I prefer to compare as shown in the documentation to keep the semantic understandability as easy as
possible.