The document root is /var/www, I want to download the web page into /var/www/php.html
<?php
$url = "http://php.net";
$html_content = file_get_contents($url);
$fp = fopen("php.html","a");
fwrite($fp,$html_content);
fclose($fp);
echo $html_content;
?>
I can get the web page in firefox, but where is my php.html file ?
Your page is located in the same folder of your PHP script. If you want access to the page you should something like use http://path_to_your_script/pythons.html
To save in your /var/www you should use this:
<?php
$url = "http://localhost/postgres";
$html_content = file_get_contents($url);
$fp = fopen("/var/www/php.html","a"); // ADD /var/www to the path
fwrite($fp,$html_content);
fclose($fp);
echo $html_content;
?>
Now you can access with http://localhost/php.html
If you can't save in /var/www/ is because you don't have permission, if you have root permission you can execute this in the console: sudo chmod 777 /var/www/