|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-08-22 16:23 UTC] shenkong@php.net
Description:
------------
class A {
public function test() {
var_dump($this);
$this = 'oh, mygod';
var_dump($this);
}
}
$a = new A;
$a->test();
Fatal error: Cannot re-assign $this in D:\www\testthis.php on line 13
Reproduce code:
---------------
class A {
public function test($arr) {
var_dump($this);
extract($arr);
var_dump($this);
}
}
$a = new A;
$arr['this'] = 'abc';
$a->test($arr);
Expected result:
----------------
Fatal error: Cannot re-assign $this in D:\www\testthis.php on line 13
Actual result:
--------------
it's ok!
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 15:00:01 2025 UTC |
class B { public function test1() { echo 'b'; } } class A { public function test($arr) { extract($arr); var_dump($this); $this->test1(); } public function test1() { echo 'a'; } } $a = new A; $b = new B; $arr['this'] = $b; $a->test($arr); ----- object(B)#2 (0) { } a