您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php实现进度条原理

2024/3/8 14:34:24发布21次查看
php实现进度条的原理:
模版替换,在页面设置一个标识,轮子自己的页面,不发请求给服务器,由服务器端获得进度,然后替换该页面标识,达到进度条效果。
页面代码:
<!doctype html public "-//w3c//dtd html 4.0 transitional//en"><html><head><meta http-equiv="expires" content="fri, jan 01 1900 00:00:00 gmt"><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="content-type" content="text/html; charset=utf-8"><meta http-equiv="lang" content="en"><meta name="author" content=""><meta http-equiv="reply-to" content="@.com"><meta name="generator" content="phped 5.8"><meta name="description" content=""><meta name="keywords" content=""><meta name="creation-date" content="01/01/2009"><meta name="revisit-after" content="15 days"><title>进度条</title><script type="jquery.min.js"></script><script type="text/javascript">function test(){ location.reload(); settimeout('test()',1000)}</script></head> <body οnlοad="test()"> <div id="test">0</div> <div id="" style="width: 100;">{%a%}</div></body></html>
服务器代码:
<?php for($i = 0;$i < 6;$i++){ echo $i.'<br/>'; echo str_repeat(' ' ,2024); $url = '/t/test.php'; header("location: " . $url.'&id='.$i); $read_url = realpath('.'.$url); $content = file_get_contents('d:/phpnow/htdocs11/design/t/test.php'); $rr = preg_replace('/{%(.*)%}/','{%'.$i.'%}',$content); file_put_contents('d:/phpnow/htdocs11/design/t/test.php',$rr); ob_flush(); flush(); sleep(1); }?>
以上就是php实现进度条原理的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product