php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #40263 Can't set associativity for variable member access.
Submitted: 2007-01-28 15:51 UTC Modified: 2007-01-28 16:01 UTC
From: jbailey at raspberryginger dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
 [2007-01-28 15:51 UTC] jbailey at raspberryginger dot com
Description:
------------
There is no way of doing $a->$b->a where I really want $a->($b->a)

Reproduce code:
---------------
class a {}
class b {}

$a = new a();
$b = new b();

$a->foo = "foo";
$a->bar = "bar";

$b->a = "foo";
$b->b = "bar";

$temp=$b->a;
echo $a->$temp;

echo $a->($b->a);


Expected result:
----------------
The lines:

echo $a->$temp;

echo $a->($b->a);

should each output the same thing.

Actual result:
--------------
Parse error: syntax error, unexpected '(', expecting T_STRING or T_VARIABLE or '{' or '$' in /tmp/test.php on line 18


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 09 16:02:26 2025 UTC