PHP에서 마이크로 시간 함수를 사용할 때 이상한 문제가있는 것 같습니다. 내 index.php를에 나는 그것 (잘못) 2.00 초에서 아무것도의 시간을 보여줍니다 내 index.php에 갈 때 loadtime.php다른 결과를 반환하는 PHP 마이크로 시간
$host = $_GET['host'];
$time = microtime(TRUE);
file_get_contents($host);
$time = microtime(TRUE) - $time;
echo $time;
에
$.ajax({
url:'loadtime.php',
datatype:"application/json",
type:'get',
data: "host=http://www.mywebsite.com",
success:function(data){
document.getElementById('loadtime_com').innerHTML = data;
},
error:function(){
// code for error
}
});
다음 있습니다. 나는 다음 다른 PHP 파일이라고 loadtime2.php을 작성
$host = "http://www.mywebsite.com";
$time = microtime(TRUE);
file_get_contents($host);
$time = microtime(TRUE) - $time;
echo $time;
에 코드를 변경 그리고 mywebsite.com/loadtime2.php로 이동하여 스크립트를 테스트하고이 5.00 초 동안 나에게 시간을 제공합니다. 나는이 불일치를 일으키는 것을 해결할 수 없다. 마치 웹 사이트 내용을 얻는 시간 대신 index.php에서 loadtime.php를 검색 할 시간을 마이크로 타임이 제공하는 것과 같다.