Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

stream_context_set_option

Description

The stream_context_set_option of Stream for PHP sets an option for a stream/wrapper/context.

Syntax

stream_context_set_option(
    resource $stream_or_context,
    string $wrapper,
    string $option,
    mixed $value
): bool
stream_context_set_option(
    resource $stream_or_context,
    array $options
): bool

Parameters

stream_or_context

The stream or context resource to apply the options to.

wrapper

The name of the wrapper (which may be different than the protocol).

option

The name of the option.

value

The value of the option.

options

The options to set for stream_or_context.

NOTE: Options must be an associative array of associative arrays in the format $array['wrapper']['option'] = $value.

Return

Returns true on success or false on failure.

Examples

1 · stream_or_context wrapper option value

<?

$stream_or_context = stream_context_create();
$wrapper = "http";
$option = "method";
$value = "POST";

$return = stream_context_set_option($stream_or_context, $wrapper, $option, $value);

var_export($return);

?>
true

2 · stream_or_context options

<?

$stream_or_context = stream_context_create();
$options = ["http" => ["method" => "POST"]];

$return = stream_context_set_option($stream_or_context, $options);

var_export($return);

?>
true
HomeMenu