©
이 문서에서는 PHP 중국어 웹사이트 매뉴얼 풀어 주다
(PECL pecl_http >= 0.12.0)
HttpRequest::setHeaders — Set headers
$headers
] )Set request header name/value pairs.
headers
an associative array as parameter containing header name/value pairs; if empty or omitted, all previously set headers will be unset
成功时返回 TRUE
, 或者在失败时返回 FALSE
。
[#1] quickshiftin at gmail dot com [2008-06-13 23:29:08]
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