Bug #64300 [Opn->Nab]: Varible Property Retrivel
| From: | nikic@php.net | Date: | Tue, 26 Feb 2013 07:03:39 +0000 |
| Subject: | Bug #64300 [Opn->Nab]: Varible Property Retrivel | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-177416@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64300&edit=1
ID: 64300
Updated by: nikic@php.net
Reported by: jyoung at mycarepro dot com
Summary: Varible Property Retrivel
-Status: Open
+Status: Not a bug
Type: Bug
Package: Class/Object related
Operating System: Windows 8
PHP Version: 5.4.12
Block user comment: N
Private report: N
New Comment:
The -> operator is left associative, so $p->$this->b is interpreted as
($p->$this)->b.
Instead you should write $p->{$this->b} to get the desired effect.
Previous Comments:
------------------------------------------------------------------------
[2013-02-25 23:16:47] jyoung at mycarepro dot com
Description:
------------
Varible Property Retrivel
Test script:
---------------
class y{
public $u = 123;
}
class a{
public $b = null;
public function __construct($test){
$this->b = $test;
}
public function $c(){
$p = new y();
$p->u; //Works
$p->$this->b; //Causes Error???
$tmp = $this->b;
$p->$tmp; //Works
}
}
$xyz = new a('u');
$xyz->c();
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64300&edit=1