Pretty straightforward; I’ve read through the docs but perhaps I’m just a tad confused by the explanation.
class Test{
public static $var = 'world';
}
echo "hello {Test::$var}"; // only parses $var in current scope, which is empty
Is there any way to achieve the desired functionality here? I’m starting to guess no, as I’ve tried a number of permutations with no success.
Clarification: I’m trying to achieve this with PHP’s variable parsing, not concatenation. Obviously I’ll resort to concatenation if the desired method is not possible, though I’m hoping it is.
Variable parsing in PHPs double quoted strings only works for “variable expressions“. And these must always start with the byte sequence
{$. Your reference to a static identifier however starts with{Thencewhy PHP parses towards the next$in your double quotes and ignoresTest::You need to utilize some cheat codes there. Either use a NOP wrapper function:
Or pre-define the class name as variable:
I’m afraid there’s no native way to accomplish this otherwise.