Saeed Afzal
Saeed Afzal

Reputation: 368

Is is possible to get file output buffer without including the file?

Is it possible to get file output buffer string to execute the file in background instead of including it?

Right now this is the only way which I have seen. See code below;

ob_start();
include($file);
$html = ob_get_contents();
ob_end_clean();

But I have list of files which I don't want to include. I just want to execute the file in background process for getting output buffer string.

Can anyone please help me on it?

Thanks Smac

Upvotes: 1

Views: 380

Answers (1)

Sachin Joshi
Sachin Joshi

Reputation: 119

If your file is php you need to use include.For multiple files you can use function like this I found here

function include_multi($files) {
    $files = func_get_args();
    foreach($files as $file)
        include($file);
}

And call it with

include_multi("one.php", "two.php", ..);

Also If you want plain file contents(No need to execute file) you can use file_get_contents or readfile

Upvotes: 1

Related Questions