Back to index

php5  5.3.10
tokenizer.php
Go to the documentation of this file.
00001 <?php
00002 
00003 if(!extension_loaded('tokenizer')) {
00004            dl('tokenizer.so');
00005 }
00006 
00007 $fp = fopen('php://stdin', 'r');
00008 while (!feof($fp)) {
00009        $content .= fread($fp, 4096);
00010 }
00011 fclose($fp);
00012 
00013 $tokens = token_get_all($content);
00014 
00015 $count = count($tokens);
00016 $state = 0;
00017 for ($i = 0; $i < $count; $i++) {
00018        $token = $tokens[$i];
00019        if (is_array($token)) {
00020               if ($state == 1 && $token[0] == T_STRING) {
00021                      $token[1] = preg_replace('!([a-z])([A-Z])!e', '"$1_".strtolower("$2")', $token[1]);
00022                      $state = 0;
00023               } else if ($token[0] == T_FUNCTION) {
00024                      $state = 1;
00025               }
00026               $chunk = $token[1];
00027        } else {
00028               $chunk = $token;
00029        }
00030        $output .= $chunk;
00031 }
00032 
00033 print $output;
00034 
00035 ?>