示例#1
0
$file = fopen("php_functions.csv", "w");
$fields = [];
error_reporting(E_ALL & ~E_WARNING);
//sizeof($function_list)
for ($i = 0; $i < 3; $i++) {
    $string = "";
    $function_url = "http://php.net/manual/en/function." . str_replace("_", "-", $function_list[$i]) . ".php";
    $html = phpQuery::newDocumentFile($function_url);
    if (strpos(error_get_last()["message"], "404 Not Found") == false) {
        $num_of_functions++;
        echo "Fetching {$function_url}... \n";
        $name = $function_list[$i];
        foreach (get_defined_constants(true)["user"] as $key => $value) {
            if (!in_array(substr($key, 0, 4), $invalid_keys)) {
                foreach (pq(constant($key)) as $element) {
                    $string = $string . process_string($element->textContent, $name);
                }
            }
        }
        $info = $string;
        echo "<span style='font-weight:bold'>{$function_list[$id]}</span> <BR> {$info}";
        fwrite($file, "\"{$name}\", \"{$info}\" \n");
    } else {
        echo "{$function_list[$i]} - {$function_url} does not exist.\n";
    }
    sleep(1);
}
fclose($file);
echo "{$num_of_functions} out of " . sizeof($function_list) . " functions have been processed.";
function process_string($string, $name)
{
示例#2
0
             $quote_mode = 'single';
             $mode = "string_to";
         } else {
             if ($translations[$i] == '"') {
                 $quote_mode = 'double';
                 $mode = "string_to";
             } else {
                 die("Parse error at character " . $i . ". Mode: " . $mode . ". Character: " . $translations[$i] . ". String from: " . $string_from . " Context: " . error_context($translations, $i));
             }
         }
     }
     break;
 case 'string_to':
     if ($quote_mode == 'single' && ($translations[$i] == "'" && $translations[$i - 1] != '\\') || $quote_mode == 'double' && ($translations[$i] == '"' && $translations[$i - 1] != '\\')) {
         $mode = 'whitespace_after';
         $parsed[$string_from] = process_string(implode('', $string));
         $string = array();
     } else {
         $string[] = $translations[$i];
     }
     break;
 case 'whitespace_after':
     if ($translations[$i] == ' ' || $translations[$i] == "\n" || $translations[$i] == "\t") {
         continue;
     } else {
         if ($translations[$i] == ',') {
             $mode = "whitespace_before";
         } else {
             die("Parse error at character " . $i . ". Mode: " . $mode . ". Character: " . $translations[$i] . ". String from: " . $string_from . " Context: " . error_context($translations, $i));
         }
     }