Uma*_*til 0 php regex comments file
我的文件在顶部有评论.
例如
/**
* Comments for file.
*
*/
Run Code Online (Sandbox Code Playgroud)
使用PHP,我使用file_get_contents将文件内容读入变量现在我想在注释中获得值.对于上面的例子,预期结果将是
* Comments for file
*
*
Run Code Online (Sandbox Code Playgroud)
这意味着我想要内容/**和*/.这个文件可以有多个注释,但我想要第一个位于文件顶部的文件.
有什么想法/帮助吗?
更新: - 这是普通的文本文件.不是PHP文件.
您可以使用tokenizer阅读评论
$source = file_get_contents('example.php');
$tokens = token_get_all($source);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
110 次 |
| 最近记录: |