HttpRequest
在线手册:中文 英文
PHP手册

HttpRequest::__construct

(PECL pecl_http >= 0.10.0)

HttpRequest::__constructHttpRequest constructor

说明

public HttpRequest::__construct ([ string $url [, int $request_method = HTTP_METH_GET [, array $options ]]] )

Instantiate a new HttpRequest object.

参数

url

the target request url

request_method

the request method to use

options

an associative array with request options

错误/异常

Throws HttpException.


HttpRequest
在线手册:中文 英文
PHP手册
PHP手册 - N: HttpRequest constructor

用户评论:

RLK (15-Jul-2010 09:51)

You can use custom methods here if you use the undocumented HttpRequest::methodRegister()

<?php
HttpRequest
::methodRegister('foobar');
$r = new HttpRequest('http://www.php.net', HttpRequest::METH_FOOBAR);
?>

andychr17 at hotmail dot com (30-Jun-2008 03:34)

I found that by not having a trailing slash (e.g. "http://www.google.com"), HttpRequest would tack on the URI of the script I was currently accessing.

An easy way to prevent this from happening is to include a trailing slash in the url. This way, "http://www.google.com" becomes "http://www.google.com/".