Edit report at https://bugs.php.net/bug.php?id=9195&edit=1

 ID:                 9195
 Comment by:         larue...@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] larue...@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

Reply via email to