有没有一种方法可以检查文件中是否存在类而不包含/需要该类?
就像是:class_in_file($file);
正如我已经提到的,我知道这可以通过要求/包括课程然后查找来完成class_exists($class);
,但还有其他方法吗?
$tokens = token_get_all(file_get_contents('foo.php'));
然后检查令牌,看看是否可以发现某个特定的T_CLASS
entry.
http://www.php.net/manual/en/function.token-get-all.php http://www.php.net/manual/en/function.token-get-all.php
http://www.php.net/manual/en/tokens.php http://www.php.net/manual/en/tokens.php
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)