Questions tagged [ob-start]

ob_start is a PHP function which turns output buffering on. While output buffering is active no output is sent from the script (other than headers), instead the output is stored in an internal buffer.

190 questions
4
votes
3 answers

Email function using templates. Includes via ob_start and global vars

I have a simple Email() class. It's used to send out emails from my website. I also have a bunch of email templates written in plain HTML pierced with a few PHP variables. E.g.…
Geo
  • 12,666
  • 4
  • 40
  • 55
3
votes
2 answers

What do ob_start and ob_gzhandler functions really do

I know that ob_start turns on output buffering, but I don't fully understand what it means. To me it means that it just stops outputting the script data. Is this true? How does the browser output data in this case, do I have to use ob_end_flush()…
Eve
  • 193
  • 1
  • 6
3
votes
1 answer

Can I use ob_clean() without ob_start() before?

I am not used to ob_* functions and I began by reading the documentation. I would like to use ob_clean() in a method but the documentation says: The output buffer must be started by ob_start() with PHP_OUTPUT_HANDLER_CLEANABLE flag. Otherwise…
AymDev
  • 6,626
  • 4
  • 29
  • 52
3
votes
3 answers

Unwanted space between php and html

I have this code, the problem is that there is an empty space before each comma. Name Lastname , (1990.) , Title ... It should be Name Lastname, (1990.), Title ... I need to have data in this format using echo. ob_start(); ...
Ivan Topić
  • 3,064
  • 6
  • 34
  • 47
3
votes
2 answers

How to tell if ob_gzhandler is working?

How can I check to see if ob_start("ob_gzhandler"); is working and test the difference with or without it? Thanks,
Amien
  • 954
  • 2
  • 11
  • 18
3
votes
2 answers

PHP Should I use ob_clean after ob_start

I made a simple login-system in php and mysql, but I keep getting errors saying that headers already been sent, and using ob_start fixes this problem, but im not sure if I should then use ob_clean at the footer afterward? Also, the error comes when…
kevin ols
  • 127
  • 1
  • 2
  • 6
3
votes
1 answer

CodeIgniter with PHPABTest

I'm building a CodeIgniter site, and attempting to use php ABTest in the controller. I saved the phpabtest.php file as phpabtest_helper.php in the "helpers" folder, and loaded it in the controller. It's initialized in the PHP logic as such: public…
derrickkwa
  • 51
  • 2
3
votes
1 answer

ob_start echo's strings out still

I'd like it if ob_start() didn't let echo's output to their normal destination and just log their contents instead. But it doesn't seem to be doing that. Any ideas? Here's my code:
neubert
  • 15,947
  • 24
  • 120
  • 212
3
votes
1 answer

Ajax broken by Wordpress warnings: solve trough ob_start()?

I am writing a plugin for WordPress. My goal is make it work for everyone. Some pages use ajax responses. Some users have activated the WP_DEBUG constant that shows errors and warnings from themes and other plugins. This breaks my Ajax PHPs because…
user1524745
  • 61
  • 1
  • 7
2
votes
3 answers

Remove HTML using PHP (ob_start + dom parser)

I need to learn how to remove html tags using PHP. This is what I have in mind (I think DOM phrasing is what I need but I cant figure out how it works. A working example would be a big help for me. I can't install any external library’s and I am…
Hakan
  • 3,835
  • 14
  • 45
  • 66
2
votes
1 answer

Why inside ob_start file_put_contents is nowhere to be found?

I really need to use ob_start with PHP in my code. So I have this: ob_start("function123"); So inside function "function123" I have this: file_put_contents("aaa.txt","xxxx"); However I cant find this file anywhere. The PHP script has 777…
2
votes
3 answers

PHP ob_start & flush - print and clean text in loop

Is it possible to print text on the screen using ob_start() & flush() and finally clean this text? Now I have something like that: '; flush(); …
Majkson
  • 227
  • 4
  • 15
2
votes
3 answers

ob_start doesn't work with some functions

I am trying to catch the following error due to imagecreatefromjpeg function. Corrupt JPEG data: premature end of data segment I don't want to display this error in the output of my PHP script so I try to use ob_start and ob_get_contents but it…
Buddy
  • 21
  • 2
2
votes
0 answers

debug_backtrace() fails while in output buffering callback

Recently, an application echoed certain stuff at a random point of execution. Finding the exact statement turned out to be a problem: Too many statements emitted stuff. Thefore, I registered a callback via ob_start() to let the callback echo a…
SteAp
  • 11,853
  • 10
  • 53
  • 88
1
2
3
12 13