Рекурсивный акроним словосочетания «PHP: Hypertext Preprocessor»
Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 18820 программистов и 1632 робота. Сейчас ищут 1783 программиста ...
Request headers
Вернуться к: HTTP_Request
Request headers
Request headers – Adding additional headers to the HTTP request.
Adding a custom request header
In this example a HTTP header X-PHP-Version is added to the HTTP request. The value of this header is the version string of the PHP interpreter that is running the instance of HTTP_Request.
<?php
require_once "HTTP/Request.php";
$req =& new HTTP_Request("http://example.com/");
$req->addHeader("X-PHP-Version", phpversion());
$response = $req->sendRequest();
if (PEAR::isError($response)) {
echo $response->getMessage();
} else {
echo $req->getResponseBody();
}
?>
Headers that have been added to the HTTP_Request object can be removed with the method removeHeader(), before sendRequest() has been called.
Вернуться к: HTTP_Request