|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35548 $class->${'varname'} does not work
Submitted: 2005-12-04 21:58 UTC Modified: 2005-12-05 01:43 UTC
From: capiCrimm at gmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.1.1 OS: GNU Debian Sarge
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: capiCrimm at gmail dot com
New email:
PHP Version: OS:


 [2005-12-04 21:58 UTC] capiCrimm at gmail dot com
Where you can do ${'var'} with a normal variable trying to 
do the same thing with a class prop. results in a fatal 
error. It happens inside{$this} and outside the class. 
With public, private, and protected. It does work 
correctly with static variables. 

Reproduce code:

class Test
  protected $variable = 'one';

  public function test(){
    print $this->variable;
    print $this->${'variable'};

$t = new Test;


Expected result:

Actual result:
 Fatal error: Cannot access empty property 
in /www/unstable/apache2/php5/admin/mRio/mRioDUM/bella1/test.php 
on line 9 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-04 22:06 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

>Where you can do ${'var'} with a normal variable 
That doesn't work either.
 [2005-12-04 23:35 UTC] capiCrimm at gmail dot com
I'll agree that this may not be a bug, rather how you  
choose to develop the engine. However ${} does work with  
normal variables and class static variables. The following 
prints ``five'' as  
$one = 'five';  
print ${'one'};  
 [2005-12-05 01:43 UTC] capiCrimm at gmail dot com
eh. I figured it out, instead of $this->${'var'} you use 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Feb 23 05:01:27 2024 UTC