Discussion:
Bug #34358 [Csd]: Fatal error: Cannot re-assign $this
(too old to reply)
p***@php.net
2010-09-03 21:34:01 UTC
Permalink
Edit report at http://bugs.php.net/bug.php?id=34358&edit=1

ID: 34358
Updated by: ***@php.net
Reported by: pacha dot shevaev at gmail dot com
Summary: Fatal error: Cannot re-assign $this
Status: Closed
Type: Bug
Package: Scripting Engine problem
Operating System: *
PHP Version: 5.*
Assigned To: dmitry
Block user comment: N

New Comment:

It is not allowed anymore for obvious reasons. Please read the migration
guide and the PHP manual for more details.


Previous Comments:
------------------------------------------------------------------------
[2010-09-03 23:12:07] az_startreker at yahoo dot com

$this = mysql_last_id();

I got the same error as previously stated. Worked fine in PHP 4. I use
the variable $this in the very next line of code for a database entry,
but it keeps kicking back fatal errors at this line.

------------------------------------------------------------------------
[2005-10-21 10:07:38] ***@php.net

This bug is fixed.

Disallowing $a = &$this; and foo(&$this) is a feature request (not a
bug). Also I don't see any sense no breake BC and valid code only
because this assignment is dangerous.

------------------------------------------------------------------------
[2005-10-04 08:01:48] pacha dot shevaev at gmail dot com

Guys your notes about possible misuse($ref =& $this;$ref = 'foo') are
totally valid but is soooooo much difficult to spot this situation
_when_it_actually_happens_?

I'm by no means going to use this ref improperly but simply want BC with
PHP4...

------------------------------------------------------------------------
[2005-10-03 12:42:48] ***@php.net

I'm reopening this so that we can discuss it. I don't think we should be
silently ignoring references as that's something vague. See mail to
internals@ in a bit.

------------------------------------------------------------------------
[2005-10-03 12:14:59] ***@php.net

So for the curious who are wondering what "fixed" means. The & is
simply ignored in this case now.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

http://bugs.php.net/bug.php?id=34358
--
Edit this bug report at http://bugs.php.net/bug.php?id=34358&edit=1
az_startreker at yahoo dot com
2010-09-03 21:12:07 UTC
Permalink
Edit report at http://bugs.php.net/bug.php?id=34358&edit=1

ID: 34358
Comment by: az_startreker at yahoo dot com
Reported by: pacha dot shevaev at gmail dot com
Summary: Fatal error: Cannot re-assign $this
Status: Closed
Type: Bug
Package: Scripting Engine problem
Operating System: *
PHP Version: 5.*
Assigned To: dmitry
Block user comment: N

New Comment:

$this = mysql_last_id();

I got the same error as previously stated. Worked fine in PHP 4. I use
the variable $this in the very next line of code for a database entry,
but it keeps kicking back fatal errors at this line.


Previous Comments:
------------------------------------------------------------------------
[2005-10-21 10:07:38] ***@php.net

This bug is fixed.

Disallowing $a = &$this; and foo(&$this) is a feature request (not a
bug). Also I don't see any sense no breake BC and valid code only
because this assignment is dangerous.

------------------------------------------------------------------------
[2005-10-04 08:01:48] pacha dot shevaev at gmail dot com

Guys your notes about possible misuse($ref =& $this;$ref = 'foo') are
totally valid but is soooooo much difficult to spot this situation
_when_it_actually_happens_?

I'm by no means going to use this ref improperly but simply want BC with
PHP4...

------------------------------------------------------------------------
[2005-10-03 12:42:48] ***@php.net

I'm reopening this so that we can discuss it. I don't think we should be
silently ignoring references as that's something vague. See mail to
internals@ in a bit.

------------------------------------------------------------------------
[2005-10-03 12:14:59] ***@php.net

So for the curious who are wondering what "fixed" means. The & is
simply ignored in this case now.

------------------------------------------------------------------------
[2005-10-03 10:22:47] ***@php.net

Fixed in CVS HEAD and PHP_5_1.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

http://bugs.php.net/bug.php?id=34358
--
Edit this bug report at http://bugs.php.net/bug.php?id=34358&edit=1
Loading...