当前位置: 代码迷 >> PHP >> fsockopen,fopen,file_get_contents 为啥fsockopen是最快的呢
  详细解决方案

fsockopen,fopen,file_get_contents 为啥fsockopen是最快的呢

热度:605   发布时间:2012-12-30 10:43:15.0
fsockopen,fopen,file_get_contents 为什么fsockopen是最快的呢
query_time_class.inc.php

<?php
    class query_time_class{
        
        var $start_time;
        var $end_time;
        
        function query_start(){
            
            $this->start_time = 0;
            $this->end_time   = 0;
            $this->start_time = $this->get_cur_sec();
            
        }
        
        function query_end(){
            
            $this->end_time = $this->get_cur_sec();
            
        }
        
        function get_query_time(){
            
            $time = floatval($this->end_time - $this->start_time);
            $time = sprintf("%01.4f",$time);
            return $time;
            
        }
        
        function get_cur_sec(){
            
            list($msec,$sec) = explode(" ", microtime());
            $msec            = floatval($msec);
            $sec             = floatval($sec+$msec);
            return $sec;
            
        }
        function out_put(){
            
            $time   = $this->get_query_time();
            $output = "执行时间 {$time} 秒";
            echo $output;
            
        }
        
    } 


?>



执行代码