How do I load a PHP file into a variable?

后端 未结 8 1486
清歌不尽
清歌不尽 2020-11-30 19:20

I need to load a PHP file into a variable. Like include();

I have loaded a simple HTML file like this:

$Vdata = file_get_contents(\"text         


        
8条回答
  •  醉酒成梦
    2020-11-30 20:06

    Theoretically you could just use fopen, then use stream_get_contents.

    $stream = fopen("file.php","r");
    $string = stream_get_contents($stream);
    fclose($stream);
    

    That should read the entire file into $string for you, and should not evaluate it. Though I'm surprised that file_get_contents didn't work when you specified the local path....

提交回复
热议问题