Home » Categories » PHP

How do you define a PHP include as a string?

<?PHP
function return_output($file){
    ob_start();
    include $file;
    return ob_get_clean();
}
$content = return_output('some/file.php')


Reference:
https://stackoverflow.com/questions/2150194/how-do-you-define-a-php-include-as-a-string
Article Rating (No Votes)
Rate this article
  • Icon PDFExport to PDF
  • Icon MS-WordExport to MS Word
 
Attachments Attachments
There are no attachments for this article.
Comments Comments
There are no comments for this article. Be the first to post a comment.
Related Articles RSS Feed
PHP Warning: PHP Startup: Unable to load dynamic library ’curl’
Viewed 582 times since Thu, Feb 3, 2022
Using PHP “openssl_encrypt” and “openssl_decrypt” to Encrypt and Decrypt Data
Viewed 1133 times since Sun, Oct 4, 2020
Where is path for rh-php73 in CentOS
Viewed 607 times since Fri, Feb 5, 2021
ImageTTFtextBlur $> Is there any way to make image with text shadow in PHP with GD?
Viewed 1030 times since Thu, Sep 17, 2020
Server error: Connection reset by peer | End of script output before headers
Viewed 909 times since Mon, Feb 28, 2022
"End of script output before headers" in Apache + PHP
Viewed 437 times since Sun, Feb 27, 2022
How to Install ionCube Loader in CentOS 7
Viewed 373 times since Fri, Feb 5, 2021