Mega Code Archive

 
Categories / Php / File Directory
 

Calling fopen() with a Context Resource

<?php $url = "http://www.rntsoft.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 ); } ?>