test1.php文件如下:function posttohost($url, $data) {$url = parse_url($url);if (!$url) return “couldn’t parse url”;if (!isset($url['port'])) { $url['port'] = “”; }if (!isset($url['query'])) { $url['query'] = “”; }$encoded = “”;while (list($k,$v) = each($data)) {$encoded .= ($encoded ? “&” : “”);$encoded .= rawurlencode($k).”=”.rawurlencode($v);}$fp = fsockopen($url['host'], $url['port'] ? $url['port'] : 80);if (!$fp) return “Failed to open socket to $url[host]“;fputs($fp, sprintf(“POST %s%s%s HTTP/1.0\n”, $url['path'], $url['query'] ? “?” : “”, $url['query']));fputs($fp, “Host: $url[host]\n”);fputs
...
继续阅读
(14)