Read entire file into a string in PHP
Description
The following code shows how to read entire file into a string.
Example
//w w w .java 2 s .co m
<?php
// Create a stream
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"Cookie: foo=bar\r\n"
)
);
$context = stream_context_create($opts);
// Open the file using the HTTP headers set above
$file = file_get_contents('http://www.java2s.com/', false, $context);
?>