downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

HttpRequest::setMethod> <HttpRequest::setCookies
[edit] Last updated: Fri, 25 May 2012

view this page in

HttpRequest::setHeaders

(PECL pecl_http >= 0.12.0)

HttpRequest::setHeadersヘッダを設定する

説明

public bool HttpRequest::setHeaders ([ array $headers ] )

リクエストヘッダの 名前/値 の組み合わせを設定します。

パラメータ

headers

ヘッダの 名前/値 の組み合わせを含む連想配列。 空の配列を渡したり省略したりした場合は、 これまでに設定されているヘッダがすべて削除されます。

返り値

成功した場合に TRUE を、失敗した場合に FALSE を返します。



add a note add a note User Contributed Notes HttpRequest::setHeaders
quickshiftin at gmail dot com 14-Jun-2008 08:29
note: you should not put a colon in the keys of the arrays you pass this method, it will do that for you.  and if you do put colons in the array keys, the resultant headers will have 2 colons beside one another.

so for example,
<?php
$httpRequest
->setHeaders(array('User-Agent' => 'Mozilla/1.22 (compatible; MSIE 5.01; PalmOS 3.0) EudoraWeb 2'));
?>

will result in
User-Agent: Mozilla/1.22 (compatible; MSIE 5.01; PalmOS 3.0) EudoraWeb 2

<?php
$httpRequest
->setHeaders(array('User-Agent:' => 'Mozilla/1.22 (compatible; MSIE 5.01; PalmOS 3.0) EudoraWeb 2'));
?>

will result in
User-Agent:: Mozilla/1.22 (compatible; MSIE 5.01; PalmOS 3.0) EudoraWeb 2

 
show source | credits | stats | sitemap | contact | advertising | mirror sites