I'm trying to get the contents of a specific website, write the content to a .txt file and output unformatted result in my browser. I'm able to actually write the website content to my text file, but it won't echo out in my browser. I tried using "w+" and "r+" in my original handle but that didn't do the trick. What am I doing wrong here?
$file = file_get_contents('http://www.example.com');
$handle = fopen("text.txt", "w");
fwrite($handle, $file);
fclose($handle);
$myfile = "text.txt";
$handle = fopen($myfile, "r");
$read = htmlentities(fread($handle, filesize($myfile)));
echo $read;
echo htmlentities(file_get_contents('http://www.example.com'));?