PHP 3, PHP 4, PHP 5。PHP 4.3.0以降ではhttps://
http://example.com
http://example.com/file.php?var1=val1&var2=val2
http://user:password@example.com
https://example.com
https://example.com/file.php?var1=val1&var2=val2
https://user:password@example.com
HTTP 1.0によりHTTP GETメソッドを用いてファイル/リソースに読み込み のみのアクセスが可能です。仮想ホストにホスト名でアクセスするために、 Host: ヘッダが送信されます。 iniファイルまたはストリームコンテキストにより、 user_agent文字列を設定してい る場合、リクエストの中にも含まれます。
警告 |
IISのような、いくつかの標準に 対応してないWebサーバーは、PHPに警告を発生させるような手順でデータを送信します。 このようなサーバーを使用する場合は、 error_reportingを警告を発生しないレベルまで小さくする必要があります。 PHP 4.3.7 以降では、https:// ラッパーでストリームをオープンする際に バグがある IISサーバーソフトウエアを検出することができ、この警告を抑制することができます。 あなたが ssl:// ソケットを作性するために fsockopen() を使用している場合、 自らこの警告を検出し、抑制する必要があります。 |
PHP 4.0.5以降、リダイレクトがサポートされています。これ以前のバー ジョンを使用している場合、URLの末尾にスラッシュを付ける必要があります。 (全てのリダイレクトが処理された後に)ドキュメント取得元のリソースのURLを知ることが 重要な場合、ストリームから返された一連のレスポンスヘッダを処理する必要があります。
<?php |
ストリームにより、リソースのbodyにアクセスすることが できます。ヘッダは、$http_response_header変数に保存されます。 PHP 4.3.0以降は、ヘッダは stream_get_meta_data() により取得できます。
HTTP接続は読み込みのみ可で、HTTPリソースにデータを書き込んだり、ファイルをコピーすることはできません。
注意: HTTPS は、PHP 4.3.0以降でOpenSSLのサポートを組み込んだ場合にサポートされます。
表 L-2. ラッパーの概要
属性 | サポートの可否 |
---|---|
allow_url_fopenの制限を受けるか | Yes |
読み込み可 | Yes |
書き込み可 | No |
追記可能 | No |
同時読み書き可 | N/A |
stat()をサポート | No |
unlink()をサポート | No |
rename()をサポート | No |
mkdir()をサポート | No |
rmdir()をサポート | No |
表 L-3. コンテクストのオプション (PHP 5.0.0以降)
名前 | 使用法 | デフォルト |
---|---|---|
method | GET, POST, or any other HTTP method supported by the remote server. | GET |
header | Additional headers to be sent during request. Values in this option will override other values (such as User-agent:, Host:, and Authentication:). | |
user_agent | 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. | php.ini setting: user_agent |
content | ヘッダの後に送信する追加データ。通常、POSTまたはPUTリクエストの際に使用される。 | |
proxy | URI specifying address of proxy server. (e.g. tcp://proxy.example.com:5100 ). | |
request_fulluri | 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. | FALSE |
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.