phpday 2027 - Call for Papers

stream_context_set_params

(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)

stream_context_set_params — Set parameters for a stream/wrapper/context

说明

function stream_context_set_params(resource $context, array $params): true

Sets parameters on the specified context.

参数

context

The stream or context to apply the parameters too.

params

An associative array of parameters to be set in the following format: $params['paramname'] = "paramvalue";.

Supported parameters
Parameter Purpose
notification Name of user-defined callback function to be called whenever a stream triggers a notification. Only supported for http:// and ftp:// stream wrappers.
options Array of options as in context options and parameters.

返回值

成功时返回 true, 或者在失败时返回 false。

错误/异常

Throws a TypeError if context is not a valid stream or stream context resource.

Throws a ValueError if the options entry of params is not of the form $arr['wrapper']['option'] = $value, that is, if one of its elements is not an array or has an integer key.

Throws a TypeError if the options entry of params is not an array.

Throws a TypeError if the notification entry of params is not a valid callback.

更新日志

版本 说明
8.5.0 Now throws a TypeError if the notification entry of params is not a valid callback.
8.0.0 Now throws a TypeError if context is not a valid stream or stream context resource. Previously, an E_WARNING was raised and false was returned.
8.0.0 Now throws a ValueError if the options entry of params is not of the expected form, and a TypeError if it is not an array. Previously, an E_WARNING was raised.

参见

+添加备注

用户贡献的备注

此页面尚无用户贡献的备注。
To Top