问题:
一个类明明存在,即使在当前类的定义里,使用 class_exists 检测当前类是否存在都返回 false。
如:
<?phpnamespace amsx\account;class ActiveCodeProcessor{private static $_processerPool = [];/*** @param $type* @return ActiveCodeProcessor*/public static function getCodeProcessorObj($type){if(!key_exists($type, self::$_processerPool)){$className = 'ActiveCodeProcessor'.$type;if(class_exists($className)){self::$_processerPool[$type] = new $className;}}//......}}
解决方案:
原来是使用了命名空间后,需要使用完整的带命名空间的类名,不会因为是当前类定义而简化。
如:
<?phpecho class_exists('\think\Cache');
