Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道dirname(__FILE__),它返回调用该函数的脚本的目录。有没有办法获取get_called_class()定义返回的类的目录?
dirname(__FILE__)
get_called_class()
使用ReflectionClass:
ReflectionClass
$reflector = new ReflectionClass(get_called_class()); print dirname($reflector->getFileName()));
(这不适用于内部类:)