Maison >développement back-end >tutoriel php >mb_strlen httpdown php
if(!function_exists("mb_strlen1"))
{
function mb_strlen1($str,$enc='gb2312')
{
$l=0;
for($i=0;$i
if(ord($str[$i])>128)
{
if($enc=='gb2312')
{
$i++;
}
else if($enc=='utf8'||$enc=='utf-8')
{
$i+=2;
}
}
$l++;
}
return $l;
}
}
echo "/$l=".mb_strlen1("我市1ge中国人");
function socketData($host,$url,$headers='',$data){ $fp = @fsockopen($host, 80, $errno, $errstr, 30); if (!$fp) { return false; } else { $out = ($data?"POST":"GET")." ".$url." HTTP/1.1\r\n"; $out .= "Host: ".$host."\r\n"; $out .= $headers; $out .= "Connection: Close\r\n\r\n".$data; fwrite($fp, $out); $rtn = ""; while (!feof($fp)) { $rtn.= fgets($fp, 128); } fclose($fp); } //echo $rtn; $rtn=explode("\r\n\r\n",$rtn,2); $headerstr=explode("\r\n",$rtn[0]); //echo print_r($headerstr,1).'->'.__LINE__."
echo socketData(**.cn','/index.php',"Cookie: lstat_bc_644048=27325049701746404581; PHPSESSID=addf71fbaf5e1efd9520d1aea8a69b66/r/n")