©
本文檔使用 php中文網手册 發布
TRUE
Note: SSL options are set through an array with the single "ssl" request option name.
[#1] sandeepone at gmail dot com [2012-03-10 18:59:42]
If someone looking how to use in OOP's context:
$options = array(
'useragent' => "Firefox (+http://www.firefox.org)", // who am i
'connecttimeout' => 120, // timeout on connect
'timeout' => 120, // timeout on response
'redirect' => 10, // stop after 10 redirects
'referer' => "http://www.google.com"
);
$request = new HttpRequest('http://example.com');
$request->setOptions($options);
$request->send();
[#2] dav7 dot net at php (reverse) [2008-03-25 17:52:14]
If anyone doesn't understand the purpose of these values and is scratching their head, they're all array indexes, and are used as the $option parameter to the various HTTP functions documented in this section. For example:
<?php
$body = http_get('http://example.com/private_area/', array(httpauth => 'username:password'));
print $body;
?>
This only had me "...huh?!" for a little while, but might have others confused for longer as the fact that these are what they are isn't clearly printed anywhere... to find out that these did what they say they do was a guessing game for me even.
-dav7