If you are using stream_context_get_default() and are still finding that some functions do not work, make sure that they are not based upon the libxml functions (DOM, SimpleXML and XSLT). These require their own context.
You can easily set them using the following code ...
<?php
// Define the default, system-wide context.
$r_default_context = stream_context_get_default
(
array
(
'http' => array
( // All HTTP requests are passed through the local NTLM proxy server on port 8080.
'proxy' => 'tcp://127.0.0.1:8080',
'request_fulluri' => True,
),
)
);
// Though we said system wide, some extensions need a little coaxing.
libxml_set_streams_context($r_default_context);
?>
See http://rquadling.php1h.com/php_ntlm.php for more info (sorry for the ads).
stream_context_get_default
(PHP 5 >= 5.1.0)
stream_context_get_default — Recuperar el contexto de secuencias predeterminado
Descripción
Devuelve el contexto de secuencias predeterminado usado siempre que son llamadas las operaciones de archivos (fopen(), file_get_contents(), etc...) sin un parámetro de contexto. Las opciones para el contexto predeterminado pueden ser especificadas opcionalmente con esta función usando la misma sintaxis que en stream_context_create().
opciones debe ser una matriz de matrices asociativas en el formato $matriz['envoltura']['opcion'] = $valor.
Example #1 Uso de stream_context_get_default()
<?php
$opciones_predeterminadas = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"Cookie: foo=bar",
'proxy'=>"tcp://10.54.1.39:8000"
)
);
$opciones_alternas = array(
'http'=>array(
'method'=>"POST",
'header'=>"Content-type: application/x-www-form-urlencoded\r\n" .
"Content-length: " . strlen("baz=bomb"),
'content'=>"baz=bomb"
)
);
$predeterminado = stream_context_get_default($opciones_predeterminadas);
$alterno = stream_context_create($opciones_alternas);
/* Envia una peticion GET normal al servidor proxy en 10.54.1.39
* Solicita www.example.com usando las opciones de contexto especificadas
* en $opciones_predeterminadas
*/
readfile('http://www.example.com');
/* Envia una peticion POST directamente a www.example.com
* Usando las opciones de contexto especificadas en $opciones_alternas
*/
readfile('http://www.example.com', false, $alterno);
?>
Vea también stream_context_create(), y el Listado de envolturas soportadas con opciones de contexto (Lista de Protocolos/Envolturas Soportadas).
stream_context_get_default
02-Jan-2007 10:02
