php获取http内容的函数示例
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Lepaskan: 2016-07-25 08:54:32
asal
987 orang telah melayarinya
-
-
function http_open($url, $data, $cookie = null, $method = "GET", $timeout = 60) {
- $options = array();
- $options['http']['method'] = $method;
- $options['http']['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
- $options['http']['timeout'] = $timeout;
- if($method == "POST") :
- $length = strlen($data);
- $options['http']['header'] = "Content-type: application/x-www-form-urlencoded\r\n".
- "Content-Length: {$length}\r\n".
- "P3P: CP=\"CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR\"\r\n".
- "cookie: {$cookie}\r\n".
- "Connection: close\r\n";
- $options['http']['content'] = $data;
- else: // by bbs.it-home.org
- $options['http']['header'] = "Content-type: application/x-www-form-urlencoded\r\n".
- "P3P: CP=\"CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR\"\r\n".
- "cookie: {$cookie}\r\n".
- "Connection: close\r\n";
- endif;
$context = stream_context_create($options);
- return file_get_contents($url, 0, $context);
- }
- echo http_open("http://localhost/1.php", "username=haowei", "id=5", "POST");
-
复制代码
|
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Artikel terbaru oleh pengarang
-
2025-02-26 03:58:14
-
2025-02-26 03:38:10
-
2025-02-26 03:17:10
-
2025-02-26 02:49:09
-
2025-02-26 01:08:13
-
2025-02-26 00:46:10
-
2025-02-25 23:42:08
-
2025-02-25 22:50:13
-
2025-02-25 21:54:11
-
2025-02-25 20:45:11
Topik-topik yang berkaitan
Lagi>