php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33319 Cannot re-assign $this
Submitted: 2005-06-12 23:12 UTC Modified: 2005-06-13 00:47 UTC
From: sailormax at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.1.0b1 OS: WinXP
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: sailormax at gmail dot com
New email:
PHP Version: OS:

 

 [2005-06-12 23:12 UTC] sailormax at gmail dot com
Description:
------------
class member function do not accept bind to any variable address of $this. I do not want edit "$this"! I want work with it by another variable!
(zend.ze1_compatibility_mode = On)

Reproduce code:
---------------
<?
class foo
{
	function test($obj = '')
	{
		if ($obj == '') $obj =& $this;
	}
}
?>

Expected result:
----------------
everything must be ok

Actual result:
--------------
Fatal error: Cannot re-assign $this in index.php on line 6

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-12 23:22 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

so don\'t assign it by reference...
 [2005-06-13 00:36 UTC] sailormax at gmail dot com
But I don't re-assign "$this"! I re-assign "$obj"! Why I can't do this?
 [2005-06-13 00:47 UTC] helly@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You change $this into a reference here. Thus you still try to change it.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 10:01:26 2024 UTC