Req #9195 [Com]: Allow this be passed as default class function parameter
| From: | laruence@php.net | Date: | Wed, 06 Jul 2011 15:31:09 +0000 |
| Subject: | Req #9195 [Com]: Allow this be passed as default class function parameter | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-161662@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=9195&edit=1
ID: 9195
Comment by: laruence@php.net
Reported by: nathan at cjhunter dot com
Summary: Allow this be passed as default class function
parameter
Status: Analyzed
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: Linux
PHP Version: *
Block user comment: N
Private report: N
New Comment:
sorry for misspell:
class A {
const FOO=2;
public function dummy($a = self::FOO) {
}
}
Previous Comments:
------------------------------------------------------------------------
[2011-07-06 11:29:40] laruence@php.net
$this is in execute process, function declaring is in compile process,
but you can use a compiling variable:
class A {
const FOO = 2;
public function dummy($a = FOO) {
}
}
------------------------------------------------------------------------
[2001-02-09 13:00:53] nathan at cjhunter dot com
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 this bug report at https://bugs.php.net/bug.php?id=9195&edit=1