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
How to Install ionCube Loader in CentOS 7
Viewed 519 times since Fri, Feb 5, 2021
Server error: Connection reset by peer | End of script output before headers
Viewed 2447 times since Mon, Feb 28, 2022
"End of script output before headers" in Apache + PHP
Viewed 613 times since Sun, Feb 27, 2022
ImageTTFtextBlur $> Is there any way to make image with text shadow in PHP with GD?
Viewed 1769 times since Thu, Sep 17, 2020
Where is path for rh-php73 in CentOS
Viewed 779 times since Fri, Feb 5, 2021
PHP Warning: PHP Startup: Unable to load dynamic library ’curl’
Viewed 774 times since Thu, Feb 3, 2022
Using PHP “openssl_encrypt” and “openssl_decrypt” to Encrypt and Decrypt Data
Viewed 1334 times since Sun, Oct 4, 2020