Home  >  Article  >  Backend Development  >  fsockopen,fopen,file_get_contents 为啥fsockopen是最快的呢

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

WBOY
WBOYOriginal
2016-06-13 13:01:07896browse

fsockopen,fopen,file_get_contents 为什么fsockopen是最快的呢
query_time_class.inc.php

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



执行代码

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn