php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #32523 wrong error message assigning to $this
Submitted: 2005-04-01 00:09 UTC Modified: 2006-04-03 13:48 UTC
From: info at rhalff dot com Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 5CVS-2005-03-31 (dev) OS: debian
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2005-04-01 00:09 UTC] info at rhalff dot com
Description:
------------
The error message when assigning to $this is kinda misleading. It seems to default to cannot re-assign $this even when not in object context.

Maybe it could be defaulted to some kind of error message stating $this is a reserved variable name which can only be used in object context.





Reproduce code:
---------------
<?php $this = ''; ?>

Expected result:
----------------
something else then cannot re-assign $this...

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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-03 13:48 UTC] tony2001@php.net
$this is reserved.
Imagine that you're include'ing this code in a class where $this exists. We have to prevent $this overwriting in this case.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 20:01:35 2024 UTC