|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-12-04 21:58 UTC] capiCrimm at gmail dot com
Description:
------------
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:
---------------
<?php
class Test
{
protected $variable = 'one';
public function test(){
print $this->variable;
print $this->${'variable'};
}
}
$t = new Test;
?>
Expected result:
----------------
oneone
Actual result:
--------------
one
Fatal error: Cannot access empty property
in /www/unstable/apache2/php5/admin/mRio/mRioDUM/bella1/test.php
on line 9
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 18 13:00:02 2025 UTC |
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 expected. <?php $one = 'five'; print ${'one'}; ?>eh. I figured it out, instead of $this->${'var'} you use $this->{'var'}