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

Description

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

Sets parameters on the specified context.

Parameters

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.

Return Values

Returns true on success or false on failure.

Errors/Exceptions

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.

Changelog

Version Description
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.

See Also

User Contributed Notes

There are no user contributed notes for this page.
Adding new notes is disabled. Please see the links in the Found A Problem? section.
To Top