- token_get_all: documentation ( source)
- print_r: documentation ( source)
<?php
$sampleFileContents = <<<'TAG'
<?php
/* ---------------------------------------------------------------------------------
- PHP Version : 4.0 -
- This code was created on : 2021/11/29 at 00:10 -
- Checksum : d8d8000bfc33a4eba1e6b51b8fc71312 -
---------------------------------------------------------------------------------- */
TAG;
$tokens = token_get_all($sampleFileContents);
$comments = array();
foreach ($tokens as $token) {
if ($token[0] == T_COMMENT || $token[0] == T_DOC_COMMENT) {
$comments[] = $token[1];
}
}
print_r($comments);