Maison > Article > développement back-end > fsockopen,fopen,file_get_contents 为啥fsockopen是最快的呢
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 /> ?>