<?php $contents = <<<'PHP' <?php class AClass { public function aMethod() { \$test = true;# a comment } } PHP; $output = ''; foreach (token_get_all($contents) as $token) { if (is_string($token)) { $output .= $token; } elseif (in_array($token[0], [T_COMMENT, T_DOC_COMMENT], true)) { var_dump($token[1]); } elseif (T_WHITESPACE === $token[0]) { var_dump($token[1]); } else { $output .= $token[1]; } }
You have javascript disabled. You will not be able to edit any code.