It's worth mentioning that passing an empty array will NOT reset default options.
<?php
stream_context_set_default(array()); / Does nothing.
?>
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
stream_context_set_default — Establecer el contexto de flujo predeterminado
Establece el contexto de flujo predeterminado que será usado siempre que la operaciones de archivos (fopen(), file_get_contents(), etc...) sean llamadas sin un parámetro de contexto. Usa la misma sintaxis que stream_context_create().
options
Las opciones a establecer para el contexto predeterminado.
Nota:
options
debe ser una matriz asociativa de matrices asociativas con el formato$matriz['envoltura']['opción'] = $valor
.
Devuelve el contexto de flujo predeterminado.
Ejemplo #1 Ejemplo de stream_context_set_default()
<?php
$opcs_pred = array(
'http'=>array(
'método'=>"GET",
'cabecera'=>"Accept-language: en\r\n" .
"Cookie: foo=bar",
'proxy'=>"tcp://10.54.1.39:8000"
)
);
$predeterminado = stream_context_set_default($opcs_pred);
/* Envía una petición GET normal al servidor proxy en 10.54.1.39
* Para www.example.com usar opciones de contexto especificadas en $opcs_pred
*/
readfile('http://www.example.com');
?>
It's worth mentioning that passing an empty array will NOT reset default options.
<?php
stream_context_set_default(array()); / Does nothing.
?>
Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!
Check out: eBank.nz (Art Generator) |
Netwrck.com (AI Tools) |
Text-Generator.io (AI API) |
BitBank.nz (Crypto AI) |
ReadingTime (Kids Reading) |
RewordGame |
BigMultiplayerChess |
WebFiddle |
How.nz |
Helix AI Assistant