Rohit
Rohit

Reputation: 3137

Output buffering still outputting data

I have a simple enough code chunk:

ob_start();
include('api/emails/pmEmail.php');
$email = ob_get_contents();
ob_end_clean();

As I understand it, this should get the data in my file, parse it since it's an include, store it to $email, then end, all without outputting it to the browser.

Unfortunately, it doesn't seem to work. The file, as the name suggests, contains an email template, outputs, and because its part of an API, breaks the return. I checked my ini file, and output_buffering is set to 4096, which seems like a reasonable value. I don't know if there is some other setting I need or what I'm doing wrong. This example exists a bunch of times on the web, I don't know if its because I'm outputting a full HTML file or something else.

Upvotes: 1

Views: 111

Answers (1)

Rohit
Rohit

Reputation: 3137

Someone else pointed out this to me:

http://php.net/manual/en/function.ob-start.php#77223

There was an error in my include script that wasn't getting output. Putting that together helped me find the bug and resolve it.

Upvotes: 1

Related Questions