I need to be able to do this:
$ns = "\\common\\components\\cfoBi\\i18n\\{$countryCode}\\gimmea";
use $USP;
Obviously this won't work. So how can I do this? Have "dynamic namespaces"?
Not possible. Namespaces, imports and aliases are resolved at compile time.
However, it is possible to create objects from a class name that is built at runtime:
$className = "common\\components\\cfoBi\\i18n\\{$countryCode}\\gimmea";
$object = new $className();
See PHP docs: http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.new
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With