fsocket 返回status问题
提交资料到指定的网址
"/checking/"下有index.php echo "success"
"/checking/" 成功返回HTTP/1.1 200
"/checking" 返回HTTP/1.1 301
伺服器是Apache的,可以不用“/”也返回200吗
PHP code
"/checking/"下有index.php echo "success"
"/checking/" 成功返回HTTP/1.1 200
"/checking" 返回HTTP/1.1 301
伺服器是Apache的,可以不用“/”也返回200吗
PHP code
$host = "127.0.0.1"; $port = 8088; $script = "/checking/"; $request = ""; $request .= "username=testing&"; $request .= "password=123456"; //build header $header = "POST $script HTTP/1.1\r\n"; $header .= "Host: $host\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-length: ".strlen($request)."\r\n"; $header .= "Connection: close\r\n\r\n"; $debug.="Host: ".$host."<br />"; $debug.="Port: ".$port."<br />"; $debug.="Requset: ".$request."<br />"; $socket = fsockopen($host, $port, $errno, $errstr, 30); $output=array(); if($socket){ fputs($socket, $header.$request); $debug.="Response: "; while(!feof($socket)){ $data=fgets($socket); $debug.=$data; } echo $debug; fclose($socket); } }
作者: lochen 发布时间: 2011-05-31
可以,那你就用这种方法
$host = "127.0.0.1";
$port = 8088;
$script = "/checking/index.php";
$host = "127.0.0.1";
$port = 8088;
$script = "/checking/index.php";
作者: sibang 发布时间: 2011-06-01