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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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: Fri Dec 27 02:01:29 2024 UTC