Answer the question
In order to leave comments, you need to log in
Class name concatenation in PHP?
Hi all.
There was such a sports interest, I once read somewhere that in some version of PHP they added a feature in which you can concatenate the class name on the fly.
Only I can’t remember where it was ... And didn’t I dream about it;)
That is, so as not to write something like:
$prefix = 'My_';
$name = 'SomeClass';
$class_name = $prefix.$name;
$object = new $class_name();
$object = new {$prefix.$name};
Parse error: syntax error, unexpected '{'
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