Calling stream_context_set_option() With 2 Arguments Is Deprecated
stream_context_set_option() accepted two call shapes: a 4-argument form setting a single wrapper/option/value triple, and a 2-argument form that instead took a whole nested ["wrapper"]["option"] = value array in place of the last three arguments. PHP 8.3 added a dedicated stream_context_set_options() function for that array form. Until PHP 8.4, calling the 2-argument array form was completely silent. In PHP 8.4, it emits a deprecation notice in favor of the new function; the context is still updated exactly as before, and the call still returns true.
PHP code
<?php
$context = stream_context_create();
var_dump(stream_context_set_option($context, ['http' => ['method' => 'POST']]));
Before
bool(true)
After
PHP Deprecated: Calling stream_context_set_option() with 2 arguments is deprecated, use stream_context_set_options() instead in /codes/streamContextSetOptionTwoArgsDeprecated.php on line 4
Deprecated: Calling stream_context_set_option() with 2 arguments is deprecated, use stream_context_set_options() instead in /codes/streamContextSetOptionTwoArgsDeprecated.php on line 4
bool(true)
PHP version change
This behavior was deprecated in 8.4.
This behavior changed in .