http://w3shaman.com/article/php-progress-bar-script에서 예제를 실행하려고합니다.스크립트 완료 후 PHP 진행률 막대가 표시됩니다.
나는 windows에서 quickPHP을 사용하고 있습니다. 자습서 위의 라이브가 잘 실행중인 Demo 링크가 있습니다.
문제 :이 스크립트를 테스트 할 때
, 나는 PHP가 처리 할 경우에만 바 얻을. 나는 또한 jQuery UI 진행 막대를 사용하여 시도했지만 PHP는 진행률 표시 줄을 표시하기 전에 바쁘다가 갑자기 끝날 때 100 완료를 보여줍니다. 뭐가 잘못 되었 니 ? above link에서
코드 :
//At the beginning of your PHP file
ob_start();
...
그리고 :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<title>Progress Bar</title>
</head>
<body>
<!-- Progress bar holder -->
<div id="progress" style="width:500px;border:1px solid #ccc;"></div>
<!-- Progress information -->
<div id="information" style="width"></div>
<?php
// Total processes
$total = 10;
// Loop through process
for($i=1; $i<=$total; $i++){
// Calculate the percentation
$percent = intval($i/$total * 100)."%";
// Javascript for updating the progress bar and information
echo '<script language="javascript">
document.getElementById("progress").innerHTML="<div style=\"width:'.$percent.';background-color:#ddd;\"> </div>";
document.getElementById("information").innerHTML="'.$i.' row(s) processed.";
</script>';
// This is for the buffer achieve the minimum size in order to flush data
echo str_repeat(' ',1024*64);
// Send output to browser immediately
flush();
// Sleep one second so we can see the delay
sleep(1);
}
// Tell user that the process is completed
echo '<script language="javascript">document.getElementById("information").innerHTML="Process completed"</script>';
?>
</body>
</html>
스크립트 실행 후 여전히 동일합니다. 갑자기 보여줍니다. – django
그것은 아주 이상합니다. 그것은 나에게 잘 작동합니다. 나는 생각을 가지고있다 :'echo'를 사용하지 말아라.'...?> ... ' –
당신은 quickPHP를 사용하고 있습니까? – django