php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47575 Re-assign $this
Submitted: 2009-03-05 17:20 UTC Modified: 2009-03-05 21:00 UTC
From: kacperszurek at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.2.9 OS: Any
Private report: No CVE-ID: None
 [2009-03-05 17:20 UTC] kacperszurek at gmail dot com
Description:
------------
Re-assign $this is possible

Reproduce code:
---------------
<?php

$variable = "this";
$$variable = "test";

echo $variable; //test

Expected result:
----------------
Fatal error: Cannot re-assign $this in....

Actual result:
--------------
test

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-05 17:25 UTC] kacperszurek at gmail dot com
Description:
------------
Re-assign $this is possible

Reproduce code:
---------------
<?php

$variable = "this";
$$variable = "test";

echo $this; //test

Expected result:
----------------
Fatal error: Cannot re-assign $this in....

Actual result:
--------------
test
 [2009-03-05 21:00 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

Sure, you can do this... just not in an object context
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 03:01:35 2025 UTC