PHP Doku:: HTTP context option listing - context.http.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchSprachreferenzKontextoptionen und -parameterHTTP context options

Ein Service von Reinhard Neidl - Webprogrammierung.

Kontextoptionen und -parameter

<<Socket-Kontextoptionen

FTP-Kontextoptionen>>

HTTP context options

HTTP context optionsHTTP context option listing

Beschreibung

Context options for http:// and https:// transports.

Optionen

method string

GET, POST, or any other HTTP method supported by the remote server.

Defaults to GET.

header string

Additional headers to be sent during request. Values in this option will override other values (such as User-agent:, Host:, and Authentication:).

user_agent string

Value to send with User-Agent: header. This value will only be used if user-agent is not specified in the header context option above.

By default the user_agent php.ini setting is used.

content string

Additional data to be sent after the headers. Typically used with POST or PUT requests.

proxy string

URI specifying address of proxy server. (e.g. tcp://proxy.example.com:5100).

request_fulluri boolean

When set to TRUE, the entire URI will be used when constructing the request. (i.e. GET http://www.example.com/path/to/file.html HTTP/1.0). While this is a non-standard request format, some proxy servers require it.

Defaults to FALSE.

max_redirects integer

The max number of redirects to follow. Value 1 or less means that no redirects are followed.

Defaults to 20.

protocol_version float

HTTP protocol version.

Defaults to 1.0.

timeout float

Read timeout in seconds, specified by a float (e.g. 10.5).

By default the default_socket_timeout php.ini setting is used.

ignore_errors boolean

Fetch the content even on failure status codes.

Defaults to FALSE

Changelog

Version Beschreibung
5.3.0 Added ignore_errors.
5.2.1 Added timeout.
5.1.0 Added HTTPS proxying through HTTP proxies.
5.1.0 Added max_redirects.
5.1.0 Added protocol_version.

Beispiele

Beispiel #1 Fetch a page and send POST data

<?php

$postdata 
http_build_query(
    array(
        
'var1' => 'some content',
        
'var2' => 'doh'
    
)
);

$opts = array('http' =>
    array(
        
'method'  => 'POST',
        
'header'  => 'Content-type: application/x-www-form-urlencoded',
        
'content' => $postdata
    
)
);

$context  stream_context_create($opts);

$result file_get_contents('http://example.com/submit.php'false$context);

?>

Anmerkungen

Hinweis: Underlying socket stream context options
Additional context options may be supported by the underlying transport For http:// streams, refer to context options for the tcp:// transport. For https:// streams, refer to context options for the ssl:// transport.


Ein BenutzerBeitrag:
- Beiträge aktualisieren...
TxRx
15.12.2009 18:13
Note that if the server is not able to 'getaddresses' change the name to an ip address and that'll sort that out for internal looking calls and posts.



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)