stream_context_set_options
(PHP 8 >= 8.3.0)
stream_context_set_options — Sets options on the specified context
说明
Sets options on the specified context.
参数
context
-
The stream or context resource to apply the options to.
options
-
The options to set for
context
.注意:
options
must be an associative array of associative arrays in the format$array['wrapper']['option'] = $value
.Refer to context options and parameters for a listing of stream options.
示例
示例 #1 stream_context_set_options() example
<?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" } }
+添加备注
用户贡献的备注
此页面尚无用户贡献的备注。
备份地址:http://www.lvesu.com/blog/php/function.stream-context-set-options.php