stream_context_set_option()
stream_context_set_option() — Sets an option for a stream/wrapper/context.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
The following alternative signature is deprecated as of PHP 8.4.0, use stream_context_set_options() instead. function stream_context_set_option(resource $stream_or_context, array $options): bool
Signature
stream_context_set_option(resource $stream_or_context, string $wrapper, string $option_name, mixed $value): bool stream_context_set_option(resource $stream_or_context, array $options): bool
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $stream_or_context | resource | The stream or context resource to apply the options to. |
| $wrapper | string | The name of the wrapper (which may be different than the protocol). Refer to context options and parameters for a listing of stream options. |
| $option_name | string | The name of the option. |
| $value | mixed | The value of the option. |
| $options | array | The options to set for stream_or_context. |
Return value
Returns true on success or false on failure.
Example
The PHP manual ships no example for stream_context_set_option(); the signature and the parameter table above are the contract.
Changelog
| Version | Change |
|---|---|
| 8.4.0 | The alternative 2-parameter signature is now deprecated. Use stream_context_set_options() instead. |
All PHP 8.5 built-in functions
Reference card built from the PHP manual page stream_context_set_option() (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.