Home >Backend Development >PHP Tutorial >PHP生成大量HTML文件,如何处理内存超出
PHP生成大量HTML文件,如何避免内存超出
<br />ob_start ();<br />require 'xxx.php';<br />$temp = ob_get_contents ();<br />ob_end_clean ();<br />$fp = fopen ( $path, 'w' );<br /> fwrite ( $fp, $temp );<br /> fclose ( $fp );<br />
$total = 10;<br />$s = 0;<br />if (isset ( $_GET ['s'] )) {<br /> $s = &$_GET ['s'];<br />}<br />$per = $s + 5; // 每次循环5条<br />if ($per > $total) { // 如果下次循环会超过总数,就让他只能循环到总数<br /> $per = &$total;<br />}<br />while ( $s < $per ) {<br /> echo ++ $s;<br /> echo '<br>';<br />}<br />echo '<hr>';<br />echo $s;<br />if ($s < $total) {<br /> echo "<script>window.location.href='?s=$s'</script>";<br />}