note 14131 added to language.operators.logical.php

From: Date: Wed, 18 Jul 2001 13:59:38 +0000
Subject: note 14131 added to language.operators.logical.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-15538@lists.php.net to get a copy of this message
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! http://www.php.net/manual/en/language.operators.logical.php

« previous php.notes (#15538) next »