Statement on glibc/iconv Vulnerability

stream_context_set_options

(PHP 8 >= 8.3.0)

stream_context_set_options指定されたコンテキストのオプションを設定する

説明

stream_context_set_options(resource $context, array $options): bool

指定されたコンテキストのオプションを設定します。

パラメータ

context

オプションを適用するストリーム、またはコンテキストリソース。

options

context に設定するオプション。

注意:

options は、 $array['wrapper']['option'] = $value のフォーマットからなる連想配列でなければいけません。

ストリームオプションの一覧は コンテキストオプションとパラメータ を参照ください。

戻り値

成功した場合に true を、失敗した場合に false を返します。

例1 stream_context_set_options() の例

<?php

$context
= stream_context_create();

$options = [
'http' => [
'protocol_version' => 1.1,
'user_agent' => 'PHPT Agent',
],
];

stream_context_set_options($context, $options);
var_dump(stream_context_get_options($context));
?>

上の例の出力は以下となります。

array(1) {
  ["http"]=>
  array(2) {
    ["protocol_version"]=>
    float(1.1)
    ["user_agent"]=>
    string(10) "PHPT Agent"
  }
}

参考

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top