dynamic class property $$value in php
Posted
by cellis
on Stack Overflow
See other posts from Stack Overflow
or by cellis
Published on 2009-05-12T18:45:12Z
Indexed on
2010/04/13
17:33 UTC
Read the original article
Hit count: 257
How can i reference a class property knowing only a string?
class Foo
{
public $bar;
public function TestFoobar()
{
$this->foobar('bar');
}
public function foobar($string)
{
echo $this->$$string; //doesn't work
}
}
what is the correct way to eval the string?
© Stack Overflow or respective owner