Somewhere in the codebase there is a file abc.php with a class named abc:
<?php
namespace x\y\z;
class abc {
// ...
}
In different script, a variable with short class name (without namespace):
$className = "abc";
I need a reflection of class, but the code:
$r = new \ReflectionClass($className); //Error: Class abc does not exist in...
is not working since full class name "x\y\z\abc"
is required.
Building an object also not working for the same reason:
$obj = new $className(); // Error: Class 'abc' not found in...
How to find the full class name from the short one ?
Any suggestions are welcome.
Aucun commentaire:
Enregistrer un commentaire