Re: Sv: Re: [SMARTY] assign_by_ref() and append_by_ref()

From: Date: Sat, 03 Aug 2002 15:48:49 +0000
Subject: Re: Sv: Re: [SMARTY] assign_by_ref() and append_by_ref()
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-5577@lists.php.net to get a copy of this message
They do not recommend pass-by-reference at call time, it will probably be deprecated. So don't do this: my_func(&$var); function my_func($var) { } instead do this: my_func($var); function my_func(&$var) { } Ferdinand Beyer wrote:
On 2 Aug 2002 at 15:47, Monte Ohrt wrote:
That was the thinking, pass-by-reference at call time may cause more problems later. PHP 5.0 will fix it implicitly, so these are basically work around functions... unless someone knows of a better way to handle it? Good input, keep it coming :-) Monte
Are you sure that they want to discard references in PHP5? I will ask the engine2 team about this because references are very handy. Please don't connect references automatically with objects - you can also use them for other values. So you could assign a string to smarty and change it later without having to call assign() again. This feature (also used by PEAR) is only possible with references: <?php class MySQL { // Some implementation here function fetchInto(&$var) { $row = mysql_fetch_array($this->result); if (!is_array($var)) {
       return false;
} $var = $row; return true; } } while ($db->fetchInto($row)) { echo $row['name'] . "<br />\n"; } ?> So again: I don't see a need for assign_by_ref() or append_by_ref(). An assign() allowing both is the best solution.


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