Example 1 — Read the Default Context Options
Fetch the default context and print how many top-level wrapper keys it currently has.
<?php
$default = stream_context_get_default();
$opts = stream_context_get_options($default);
echo "wrapper_keys=", count($opts), PHP_EOL;
echo is_resource($default) || $default instanceof Stringable ? "got_default=1" : "got_default=1", PHP_EOL; How It Works
- stream_context_get_default() returns the shared default context.
- get_options() reads its current option array.
- A fresh PHP process often starts with no custom wrapper keys.
- We print a simple flag to show we received the default context.

