Execute a PHP file, and return the result as a string

前端 未结 2 1948
故里飘歌
故里飘歌 2020-12-08 22:26

Let\'s assume I have the following file - template.php:



    
        

        
相关标签:
2条回答
  • 2020-12-08 23:04

    This should do it:

    ob_start();
    include('template.php');
    $returned = ob_get_contents();
    ob_end_clean();
    
    0 讨论(0)
  • 2020-12-08 23:21

    If you don't need to do this within PHP, you could execute a php script from the command line, and pipe it to a text file, like so:

    php -f phpFile.php > output.html
    
    0 讨论(0)
提交回复
热议问题