(PHP 8 >= 8.3.0)
stream_context_set_options — 为指定的上下文设置选项
示例 #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"
}
}