note 14131 deleted from language.operators.logical by betz
| From: | betz@php.net | Date: | Mon, 01 Nov 2004 14:07:48 +0000 |
| Subject: | note 14131 deleted from language.operators.logical by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-79449@lists.php.net to get a copy of this message | ||
Note Submitter: Techek
----
I guess it's faster to && (and) and || (or) variables that is not calculated before
variables that is calculated. Example :
Slow version :
<?php
$valid = (ereg("^[0-9a-fA-F]*$",$sessionid) && $sessionid);
?>
Fast version :
<?php
$valid = ($sessionid && ereg("^[0-9a-fA-F]*$",$sessionid));
?>
Note : I'm not sure if PHP "optimizes" it's decisions on the order of variables
or something. It's just a thought!