Home >Backend Development >PHP Tutorial >php js dynamically displays the progress bar of the server running program_PHP tutorial

php js dynamically displays the progress bar of the server running program_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:08:28884browse

php教程 网页特效 动态显示服务器运行程序的进度条
if ('source' == $_get['act']) {           //查看源代码
show_source($_server["script_filename"]);
exit;
}   //end if
set_time_limit(0);
for ($i = 0; $i < 5000; $i++) {
$users[] = 'tom_' . $i;
} //end for
$width = 500; //显示的进度条长度,单位 px
$total = count($users); //总共需要操作的记录数
$pix = $width / $total; //每条记录的操作所占的进度条单位长度
$progress = 0; //当前进度条长度
?>


   
   
   
   



   
如下进度条的动态效果由服务器端 php 程序结合客户端 网页特效 程序生成。

   

   

   

   

   
0%


flush(); //Send the output to the client browser
foreach ($users as $user) {
// It is more convenient to use an empty loop here to simulate Time-consuming operations need to be replaced in actual applications;
// If your operation is not time-consuming, I think you don’t need to use this script:)
for ($i = 0; $i < 10000; $i++) {
;;
}
?>

flush(); //Send the output to the client browser so that it can immediately execute the javascript program output by the server.
$progress += $pix;
} //end foreach
// Finally, set the progress bar to the maximum value $width, and display that the operation is completed
?>

flush ();
?>



www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/444882.htmlTechArticlephp tutorial web page special effects dynamically display the progress bar of the server running program if ('source' == $_get['act ']) { //View source code show_source($_server[script_filename]); exit; } //end if set_...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn