Re: PHP 4.0 Bug #9195: Default class function arguments
| From: | Zeev Suraski | Date: | Fri, 09 Feb 2001 18:06:52 +0000 |
| Subject: | Re: PHP 4.0 Bug #9195: Default class function arguments | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-46100@lists.php.net to get a copy of this message | ||
Default function arguments have to be static, non dynamic values. The way to do it is
function foo($bar=unset)
{
if (!isset($bar)) {
$bar = ...;
}
}
At 20:00 9/2/2001, nathan@cjhunter.com wrote:
-- Zeev Suraski <zeev@zend.com> CTO & co-founder, Zend Technologies Ltd. http://www.zend.com/From: nathan@cjhunter.comOperating system: LinuxPHP version: 4.0.2 PHP Bug Type: Feature/Change RequestBug description: Default class function arguments I'm requesting that the default function arguments for a class method be able to reference the class variable members in it's definition. Here is an example of it's use: class searchclass {var $hits; var $results;function save($filename, $start = 0, $end = $this->hits){ /* <- this returns Parse error: */ if($fp = @fopen($filename, "w")){ for($i = $start; $i < $end; $i++){ fwrite($fp, implode("|", $this->results[$i])); } }else{ return false; } }function search(){ /* ... */ }} -- Edit Bug report at: http://bugs.php.net/?id=9195&edit=1 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net For additional commands, e-mail: php-dev-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net