http 콘텐츠를 가져오는 PHP 함수 예제
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
풀어 주다: 2016-07-25 08:54:32
-
-
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-urlencodedrn".
- "Content-Length: {$length}rn".
- "P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"rn".
- "cookie: {$cookie}rn".
- "Connection: closern";
- $options['http']['content'] = $data;
- else: // by bbs.it-home.org
- $options['http']['header'] = "Content-type: application/x-www-form-urlencodedrn".
- "P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"rn".
- "cookie: {$cookie}rn".
- "Connection: closern";
- 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");
-
复制代码
|
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
저자별 최신 기사
-
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
-
2025-02-25 19:56:14