I have a php file named index.php ,I want write a php code to write the index.php's output in the file index.html
the script is
$http_file = "http://".$_SERVER["HTTP_HOST"]."/index.php" ;
$handle = fopen ($http_file , "rb");
$contents = "";
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);
//open the url ,read the content and then put it into undex.html file
$filename = ABSPATH.'index.html';
if ( $handle = fopen($filename, 'w')) {
@flock($handle ,LOCK_EX );
// 将$somecontent写入到我们打开的文件中。
fwrite($handle, $contents);
@flock($handle, LOCK_UN);
fclose($handle);
}
it seems work well,but if some server does not allow to open url,what can I do?
is there any best way to solve the problem?
thanks!