Answer the question
In order to leave comments, you need to log in
How to access a class name alias using a variable?
The question may not be quite right, but that's the gist of it. There are, say, several classes:
use My\SomeClass1 as ClassA;
use My\SomeClass2 as ClassB;
.....
These classes contain constants - ClassA::CONST_A, ClassB::CONST_B and the code would be significantly reduced if it were possible to use a variable as an alias or something like that:
$className = 'ClassA';
$className::CONST_A
Tried with ${...}
Any other options?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question