php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36586 undefined $this in member function default parameter value
Submitted: 2006-03-02 08:30 UTC Modified: 2006-03-02 08:44 UTC
From: Sm0ke999 at yandex dot ru Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.1.2 OS: win xp
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: Sm0ke999 at yandex dot ru
New email:
PHP Version: OS:

 

 [2006-03-02 08:30 UTC] Sm0ke999 at yandex dot ru
Description:
------------
//undefined $this in member function default parameter value

class Test
{
	public function fnTest($that= $this)
	{
		echo __CLASS__, "::", __FUNCTION__, "\t that: ", gettype($that), "\n";
	}
}

Reproduce code:
---------------
class Test
{
	public function fnTest($that= $this)
	{
		echo __CLASS__, "::", __FUNCTION__, "\t that: ", gettype($that), "\n";
	}
}

Expected result:
----------------
Test::fnTest	 that: Object

Actual result:
--------------
[Thu Mar 02 10:19:34 2006] [error] PHP Parse error:  syntax error, unexpected T_VARIABLE in D:\\dev\\Site\\multipleinheritance.htm on line 3

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-02 08:44 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Syntax error is syntax error, that's exactly what you got.
And $this is a reserved word.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 17:01:32 2024 UTC