|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #9195 Allow this be passed as default class function parameter
Submitted: 2001-02-09 13:00 UTC Modified: 2011-11-18 06:23 UTC
Avg. Score:4.6 ± 0.7
Reproduced:8 of 8 (100.0%)
Same Version:1 (12.5%)
Same OS:3 (37.5%)
From: nathan at cjhunter dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: * OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: nathan at cjhunter dot com
New email:
PHP Version: OS:


 [2001-02-09 13:00 UTC] 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]));
			return false;

	function search(){
		/* ... */



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-01 15:55 UTC]
-Package: Feature/Change Request +Package: Scripting Engine problem
 [2010-12-01 15:58 UTC]
-Summary: Default class function arguments +Summary: Allow this be passed as default class function parameter -PHP Version: 4.0.2 +PHP Version: *
 [2011-07-06 11:29 UTC]
$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) {
 [2011-07-06 11:31 UTC]
sorry for misspell:
class A {
   const FOO=2;
   public function dummy($a = self::FOO) {
 [2011-11-18 06:23 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

 [2011-11-18 06:23 UTC]
-Status: Analyzed +Status: Bogus
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC