Calling fopen() with a Context Resource
<?php
$url = "http://www.java2s.com/index.htm";
$options = array ("http" => array ("user_agent" => "php24-test-script", "header" => "referer: http://www.example.com/index.html\r\n" ) );
$context = stream_context_create ( $options );
$res = fopen ( $url, 'r', 0, $context ) or die ( "could not open page" );
while ( ! feof ( $res ) ) {
print fgets ( $res, 1024 );
}
?>
Related examples in the same category