Created
July 1, 2017 04:48
-
-
Save yano3nora/a09573e6b5162d326f888816d4ddc5a5 to your computer and use it in GitHub Desktop.
[php: process of over execute time] Attention on old code. #php #js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$step_max = 999;// 1回の処理回数 | |
// foreachなら (count($array)-1) を上に | |
// ループ処理の外側は全部この中に... | |
?> | |
<html> | |
<head> | |
<script language="JavaScript"><!-- | |
function PageJump(){ | |
if ('function' === typeof window.PageJump2){ | |
PageJump2(); | |
} | |
} | |
// --></script> | |
</head> | |
<body onLoad="PageJump();"> | |
<? | |
echo str_pad('',256); | |
flush(); | |
$step = 0; | |
while($step < $step_max){ | |
// $step が for で言うところの $i になる | |
// メイン処理をかく、進捗を出力flush()しつつ、完了したら$is_endをtrueに | |
if($is_end == true){// 長い繰り返し処理が終わったらループを中断します。 | |
break; | |
} | |
//ときどきブラウザにパケットを送ったほうがタイムアウトは防げます。 | |
echo str_pad('',256); | |
flush(); | |
$step++; | |
} | |
if($step >= $step_max){ | |
?> | |
<p>処理が完了しました。</p> | |
</body> | |
</html> | |
<?php | |
exit; | |
} | |
?> | |
<script language="JavaScript"><!-- | |
function PageJump2(){ | |
// 処理が終わっていないときには再度、処理に戻ります。 | |
// ブラウザのキャッシュを防ぐためにクエリをUNIXタイムでつけます。 | |
location.href = "<?php echo $_SERVER['PHP_SELF'];?>?<?php time();?>"; | |
} | |
// --></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment