首页 >后端开发 >php教程 > fsockopen,fopen,file_get_contents 为啥fsockopen是最快的呢

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

WBOY
WBOY原创
2016-06-13 13:01:07912浏览

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 />
?>



执行代码

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn