Example 1 — Dump Options From a New Context
Create a context with two HTTP options and print them with var_export().
<?php
$ctx = stream_context_create([
"http" => [
"method" => "GET",
"user_agent" => "Inspect/1",
],
]);
echo var_export(stream_context_get_options($ctx), true), PHP_EOL; How It Works
- stream_context_create() stores the nested HTTP options.
- stream_context_get_options() returns that same structure.
- var_export() prints a readable PHP array.
- No URL is opened; this is inspection only.

