2011-10-06 6 views
0

sscanf/fscanf로 구문 분석 된 값 하나만 반환해야하는 경우 하나의 변수 목록을 지정하거나 선택적으로 할당 된 값을 사용해야합니까?list()로 변수 지정

E.G.

list($number) = fscanf($handle, "%d\n") 

또는

fscanf($handle, "%d\n", $number) 

는 이러한 식의 실행 속도에 어떤 차이가 있나요? 이 같은 스크립트

+1

당신이 측정 된 적이 있습니까? – alex

답변

0

그냥 벤치 마크하여 두 가지 방법 :

<?php 
function micro_time() { 
    $temp = explode(" ", microtime()); 
    return bcadd($temp[0], $temp[1], 6); 
} 

$time_start = micro_time(); 

for ($i=0; $i<100; $i++) { 

    // the code you want to benchmark 

} 

$time_stop = micro_time(); 

$time_overall = bcsub($time_stop, $time_start, 6); 
echo "Execution time - $time_overall Seconds"; 
?>