更新时间:2023-02-23 17:20:44
签出Tokenizer。
要获取名为test.php
的文件中的所有注释,您需要执行以下操作:
$tokens = token_get_all(file_get_contents("test.php"));
$comments = array();
foreach($tokens as $token) {
if($token[0] == T_COMMENT || $token[0] == T_DOC_COMMENT) {
$comments[] = $token[1];
}
}
print_r($comments);