2017-01-20 9 views
1
에 있지 온라인하지만 로컬 호스트에서 작업

나는 다음과 같은 PHP 스크립트 있습니다 :ob_flush()에서 GoDaddy

<?php 
ob_end_flush(); 
ob_start(); 
for ($i=0; $i < 10; $i++) { 
    echo "Line ".$i."</br>"; 
    ob_flush(); 
    flush(); 
    sleep(1); 
} 
ob_end_flush(); 
?> 

이 GoDaddy를 경제 호스팅 온라인 WAMP 로컬 호스트 및 인쇄 새로운 라인 각 초에 잘 작동하지만, 그것은 아무튼 일하지 마라. 10 초가 지나도 페이지로드가 발생하지 않은 경우 출력을 보여줍니다.

무엇이 잘못 될 수 있습니까?

+0

phpinfo() 함수를 호출하십시오. 별도의 PHP 스크립트에 저장하고 호스트 서버에서 실행하여 GoDaddy의 호스트 서버에서 ob_flush()가 활성화되었는지 확인하십시오. –

+0

정확히 사용되는 것은 무엇입니까? – MahmoudTarek

+0

output_buffering = On 또는 output_buffering = 4096이 PHP.ini의 output_buffering = off 대신 설정되어야합니다. – Kaylined

답변

3
It will work fine.... 

if(!ob_get_level()) ob_start(); 
echo json_encode(array('valid'=>true,'msg'=>'Flush occured.')); 
$size = ob_get_length(); 
header("Content-Type: application/json"); 
// Set the content length of the response. 
header("Content-Length: {$size}"); 
//Close the connection if you want to. 
header("Connection: close"); 
// Flush all output. 
ob_end_flush(); 
ob_flush(); 
flush(); 
// Close current session (if it exists). 
if(session_id()) session_write_close();