有没有办法检查文件中是否存在类而不包括/要求类?
就像是: class_in_file($file);
正如我已经提到的,我知道这可以通过要求/包括课程,然后查找class_exists($class);,但任何其他方式来完成?
$tokens = token_get_all(file_get_contents('foo.php'));
Run Code Online (Sandbox Code Playgroud)
然后通过代币查看您是否可以发现某个T_CLASS条目.
http://www.php.net/manual/en/function.token-get-all.php
http://www.php.net/manual/en/tokens.php
| 归档时间: |
|
| 查看次数: |
3226 次 |
| 最近记录: |