推荐:使用PHP实现蜘蛛访问日志统计本篇文章是对使用PHP实现蜘蛛访问日志统计的代码进行了详细的分析介绍,需要的朋友参考下 复制代码 代码如下: $useragent = addslashes(strtolower($_SERVER['HTTP_USER_AGENT'])); if (strpos($useragent, 'googlebot')!== false){$bot = 'Google';} elseif (strpos($u
按手册上说,这两个函数的唯一区别是,pfsockopen是持续连接,而fsockopen不是.
我写了个代码了一下:
复制代码代码如下:
< ?
php$data="1,0,721,73,1,0,0,43290000,0,60D81D509BC00451,3,FFFFFFFF";//http://10.144.99.114/SANEX_NEW/modules/subscribemanager/test.php$host = '127.0.0.1';
$url = "/aa.php";
$pffirst = false;
$times = 1000;
$startTime = microtime(true);
for ($index = 0; $index< $times; $index++) {
echo httpPost($host,$url,$data,$pffirst)."<hr><br />";}
$middleTime = microtime(true);
for ($index = 0; $index< $times; $index++) {
echo httpPost($host,$url,$data,!$pffirst)."<hr><br />";;}
$endTime = microtime(true);
echo ($pffirst?"pfsocket":"fsocket").":".($middleTime-$startTime); echo "<br />";
echo ($pffirst?"fsocket":"pfsocket").":".($endTime-$middleTime);$count=0;
//发包函数
function httpPost($host,$url,$data,$p){
global $count;
$func = $p?"pfsockopen":"fsockopen"; $conn = $func($host,80,$errno, $errstr, 30);
if (!$conn)
{
echo "$errstr ($errno)<br />\n";
return;
}
$header = "POST ".$url." HTTP/1.1\r\n";
$header.= "Host : {$host}\r\n";
$header.= "Content-type: application/x-www-form-urlencoded\r\n"; $header.= "Content-Length:".strlen($data)."\r\n"; $header.= "Connection: Keep-Alive\r\n\r\n";
$header.= "{$data}\r\n\r\n";
fwrite($conn,$header);
$count++;
echo $count.' '.$header."<br /><br />";
$resp='';
//while (!feof($conn)) {
// $resp .= fgets($conn);
/
分享:如何解决CI框架的Disallowed Key Characters错误提示用CI框架时,有时候会遇到这么一个问题,打开网页,只显示 Disallowed Key Characters 错误提示。有人说 url 里有非法字符。但是确定 url 是纯英文的,问题还是出来了。但清空浏览器历史记录和cookies后。 刷新就没问题了。有时候。打开不同的浏览器。有的浏览器会有问