stream_context_set_options()

stream_context_set_options() — Sets options on the specified context.

Built-in function of PHP 8.5. The manual lists it as available in PHP 8 >= 8.3.0. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

Signature

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

Parameters

ParameterTypeWhat it takes
$contextresourceThe stream or context resource to apply the options to.
$optionsarrayThe options to set for context.

Return value

Returns true on success or false on failure.

Example

A runnable snippet:

$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));

Output:

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

See also

stream_context_set_option()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page stream_context_set_options() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.