5 回答
TA贡献2037条经验 获得超6个赞
可以使用sock函数实现向另外一个URL POST数据,并获取返回的结果,sockopen提交POST数据例:
$sock = fsockopen("localhost", 80, $errno, $errstr, 30);
if (!$sock) die("$errstr ($errno)\n");
$data = "txt=" . urlencode("中") . "&bar=" . urlencode("Value for Bar");
fwrite($sock, "POST /posttest/response.php HTTP/1.0\r\n");
fwrite($sock, "Host: localhost\r\n");
fwrite($sock, "Content-type: application/x-www-form-urlencoded\r\n");
fwrite($sock, "Content-length: " . strlen($data) . "\r\n");
fwrite($sock, "Accept: */*\r\n");
fwrite($sock, "\r\n");
fwrite($sock, "$data\r\n");
fwrite($sock, "\r\n");
$headers = "";
while ($str = trim(fgets($sock, 4096)))
$headers .= "$str\n";
echo "\n";
$body = "";
while (!feof($sock))
$body .= fgets($sock, 4096);
fclose($sock);
echo $body;
TA贡献1772条经验 获得超5个赞
.htaccess的写法如下:
RewriteEngine On
RewriteRule ^/act/act.php/(.*)$ /act/act.php?key=$1 [R,L]
- 5 回答
- 0 关注
- 814 浏览
添加回答
举报