Skip to content

Instantly share code, notes, and snippets.

@michael34435
Last active October 26, 2016 08:43
Show Gist options
  • Save michael34435/a5027403c3a6860ff210ea9aeafa9de9 to your computer and use it in GitHub Desktop.
Save michael34435/a5027403c3a6860ff210ea9aeafa9de9 to your computer and use it in GitHub Desktop.
<?php
$fileStr = file_get_contents(YOUR_PHP_FILE_PATH);
$fileContent = "";
$commentTokens = [T_COMMENT];
$commentTokens[] = defined('T_DOC_COMMENT') ? T_DOC_COMMENT : T_ML_COMMENT;
$tokens = token_get_all($fileStr);
foreach ($tokens as $token) {
if (is_array($token)) {
if (in_array($token[0], $commentTokens))
continue;
$token = $token[1];
}
$fileContent .= $token;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment