5 回答

TA貢獻(xiàn)2037條經(jīng)驗 獲得超6個贊
可以使用sock函數(shù)實現(xiàn)向另外一個URL POST數(shù)據(jù),并獲取返回的結(jié)果,sockopen提交POST數(shù)據(jù)例:
$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貢獻(xiàn)1772條經(jīng)驗 獲得超6個贊
.htaccess的寫法如下:
RewriteEngine On
RewriteRule ^/act/act.php/(.*)$ /act/act.php?key=$1 [R,L]
- 5 回答
- 0 關(guān)注
- 866 瀏覽
添加回答
舉報