Reputation: 246
suppose i need to get value which is formed dynamically like
StaticClass::chatincon
is formed using dyanmic part $aa
$aa = icon;
echo StaticClass::chat{$aa}; // not working
what's the correct way to preferably without use of eval() // as eval r subjected to eval injection
Upvotes: 1
Views: 91
Reputation: 10573
You missed the constant
. The syntax is
constant ( string $name )
It should be
constant('StaticClass::chat'. $aa)
Upvotes: 1
Reputation: 3701
Use function constant() (as in http://www.php.net/constant) i.e :
constant('StaticClass::chat'. $aa)
Upvotes: 1
Reputation: 522636
constant("StaticClass::chat$aa")
And constants aren't "called", they're "accessed" if anything.
Upvotes: 1