I have several namespaces, which have their own exception handlers. I also have a general script which needs to reference one of exception handlers - the namespace required is held in a global string.
namespace myNamespace1;
class NewException extends \Exception
{
....
}
namespace myNamespace2;
class NewException extends \Exception
{
....
}
The $ref variable is a string containing myNamespace1 or myNamespace2. I want to alias one of the Exceptions using this global variable
global $ref;
$alias = $ref . "\NewException";
define("ex", $alias);
use ex as EX;
This doesn't give an error until I try to throw an EX. The class can then not be loaded. Is it possible to do this?