|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #35034 $this != ($this)
Submitted: 2005-10-31 12:00 UTC Modified: 2005-11-01 17:51 UTC
From: olympic at dino-online dot de Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.0.5 OS: *nix
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: olympic at dino-online dot de
New email:
PHP Version: OS:


 [2005-10-31 12:00 UTC] olympic at dino-online dot de
$this is treated as references, while ($this) not...

$this != ($this) ?? omg :)

Reproduce code:

class Bar {
        function onlyByRefPlease(&$foo) {
// ...
        function        someMemberFunc1() {
        function        someMemberFunc2() {
                $this->onlyByRefPlease(($this)); // note: 2 Braces!

$foo = new Bar();
$foo->someMemberFunc2(); // throws error

Expected result:
/* none */

Actual result:
Fatal error: Only variables can be passed by reference in /www/ on line 13


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-31 12:58 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

($this) is an expression, not a variable, thus you can not pass it by reference.
 [2005-11-01 17:51 UTC] olympic at dino-online dot de
Following your comment:

$a=new Foo();
$b=$a ; // $b references $a
$c=($a); //$c is now a copy because only variables
are referencable ? (NOPE)

Well, seems a little bitte inconsistent for me, why
different behaviours in assignment and method calls ?
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun Jul 03 16:03:37 2022 UTC