Re: [SMARTY] new plugin: mailto

From: Date: Wed, 22 May 2002 16:41:38 +0000
Subject: Re: [SMARTY] new plugin: mailto
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-4358@lists.php.net to get a copy of this message
At 16:44 22/05/02 +0200, Ivo Jansch wrote:
for ($i = 0, $j = count($mail_params); $i < $j; $i++) {
        //...
}
Wouldn't this be even faster? foreach ($mail_params as $param) { } Maybe it's slower, maybe php is optimised to do this very fast.. In any case it looks cleaner.
I use foreach extensively in my own code because it is convenient, but it is by no means efficient. As I understand it, it makes a copy of each item of the array in turn. Also (unrelated to Smarty but important to know) if you are working with objects it makes a COPY of each object and operates on that rather than operating on a reference to the original object - this is bad for performance and can lead to worrying side effects if you are expecting a method to be called on a specific object rather than a copy of it. HTH, Simon

« previous php.smarty.general (#4358) next »