简体   繁体   中英

file_put_contents of file_get_contents('index.php') will write PHP code

I want to cache ever x minutes my homepage because it has many requests and the content doesn't change that often,

This is what I'm trying:

<?php
    ini_set('error_reporting', 1);
    error_reporting(E_ALL);
    $path = '/home/......../mypath/html/';
    if(true){
        $homePage = file_get_contents($path.'index.php');
        file_put_contents('indexx.html', $homePage);
        //echo $homePage;
    }   
?>

The problem is that instead of getting the html result code it returns the php code (i am pretty sourprised about this.....)

Any idea why? and how to get the rendered version instead?

thanks

$homePage = file_get_contents($path.'index.php');

改成

$homePage = file_get_contents('http://www.yourdomainname.com/index.php');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM