Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. <?php
  2.  
  3. $fileStr = file_get_contents(YOUR_PHP_FILE_PATH);
  4. $fileContent = "";
  5. $commentTokens = [T_COMMENT];
  6. $commentTokens[] = defined('T_DOC_COMMENT') ? T_DOC_COMMENT : T_ML_COMMENT;
  7.  
  8. $tokens = token_get_all($fileStr);
  9.  
  10. foreach ($tokens as $token) {
  11. if (is_array($token)) {
  12. if (in_array($token[0], $commentTokens))
  13. continue;
  14.  
  15. $token = $token[1];
  16. }
  17.  
  18. $fileContent .= $token;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement