コード例 #1
0
<?php

// store on the file system
include 'common.php';
memLimit();
$fp = fopen("php://temp/", "rw+");
$bp = fopen("bacon-ipsum.txt", "r");
fputs($fp, stream_get_contents($bp));
rewind($fp);
print "[" . str_word_count(stream_get_contents($fp)) . "]\n";
fclose($fp);
fclose($bp);
memUsage();
memPeak();
// Where does 'php://temp' data live on the file system?
print sys_get_temp_dir() . "\n";
コード例 #2
0
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body>
  <?php 
if (!file_exists($filePath) || isset($_GET['force'])) {
    $ac = new AhoCorasick();
    $ac->setCombineResults(false);
    memUsage($memoryWhole, "Memory (AC instantiated):");
    $keywords = getKeywords();
    memUsage($memoryWhole, "Memory (keywords loaded):");
    $tree = $ac->buildTree($keywords);
    memUsage($memoryWhole, "Memory (tree built):");
    unset($keywords);
    memUsage($memoryWhole, "Memory (keywords unset):");
    saveToCache($ac, $filePath);
    memUsage($memoryWhole, "Memory (result cached):");
} else {
    $ac = unserialize(file_get_contents($filePath));
}
$res = $ac->FindAll($inputText);
memUsage($memoryWhole, "Memory (after find all):");
memUsage($memoryWhole, "Memory whole:");
unset($ac);
echo "<b>Results: </b><pre>";
var_dump($res);
echo "</pre>";
?>
</body>
</html>