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.
Questions tagged [ob-start]
190 questions
1
vote
1 answer
What is the purpose of the ob_ functions in php? (ob_start(), ob_get_contents(), etc.)
I've read the PHP documentation, but it fails to give any practical examples.
I'm using some open source code, and it contains this email function. I'm trying to understand why these ob_XXX() functions are here and what they do (because I need to…

justdoingmyjob
- 138
- 6
1
vote
4 answers
How to send the header to the client before execute the php scripts
How to send the header to the client before execute the php scripts ?
My script take many time to finish and the client don't receive anything through this period.
header("HTTP/1.1 200 OK");
header("Date: Thu, 23 Jun 2011 10:16:31…

faressoft
- 19,053
- 44
- 104
- 146
1
vote
1 answer
ob_start() slows the script
I am using ob_start('ob_gzhandler') for compressing my script.But the script takes too much time for execution. I added ob_end_flush() method in the callback function of register_shutdown_function() because i can't add ob_end_flush() directly in the…

ajay
- 355
- 3
- 8
- 17
1
vote
1 answer
ob_start callback function extract output - PHP
I would like to get output "Apples", because it is inside of span tag which has id called fruit. So what codes should be written in that callback function?

Sally Hammel
- 194
- 1
- 8
1
vote
1 answer
Output Buffer shows "1"
I have two functions:
core_function($atts) {
(attributes)
(core functions, a few loops, echoes, a lot of direct input)
}
And that's how I display my function using output buffering (yes, I have to use…

anonymous
- 1,511
- 7
- 26
- 37
1
vote
1 answer
php output buffering inserts double quotes around the picture tag
output buffering insert double quotes around the picture tag. How to fix this.
I have htmlToBeInserted.html file with contents :
1
vote
0 answers
Wordpress shortcode security - ob_start() htmlspecialchars()
I have this piece of code.
function PHP_Include( $atts )
{
$atts = htmlspecialchars($atts);
ob_start();
extract(shortcode_atts( array(
'file' => 'default'
), $atts ));
include get_theme_root() . '/' .…

subzero
- 99
- 9
1
vote
1 answer
Trapping line of code that emits first character
Suddenly, an application isn't any longer able to output ZIP files. An inspection revealed the cause: The first character of the ZIP is a blank, which breaks the ZIP format spec.
To track down this problem, I enabled CStatementTracer, which prints…

SteAp
- 11,853
- 10
- 53
- 88
1
vote
1 answer
Outputting HTML in PHP, is there any upside to using ob_start or simply echo $html?
Obviously there are usability and readability differences, but are there any advantages or disadvantages to the methods below – especially performance-wise?
function method1() {
ob_start();
?>
some html

Emin Özlem
- 809
- 7
- 13
1
vote
1 answer
PHP : insert executable php code in HTML
I got simple caching script which is saving php code into HTML. Everything works fine, but I need to add dynamic tracking code into every saved HTML by including a script from another file with include() statement
....
$s_getdata =…

Karel Sniper Žák
- 200
- 1
- 10
1
vote
1 answer
PHP - Write console output to file AND to console?
I want to write the console output to a file AND to the console itself. To write the console output to a file I'm using this:
ob_start();
...
...
$output = ob_get_contents();
file_put_contents("cronjob.txt", $output, FILE_APPEND);
ob_flush();
But…

ThisIsDon
- 25
- 4
1
vote
3 answers
php variable set with ob_get_clean is a string but won't cast to integer
I am trying to get the browser timezone via JavaScript and capture it in a php variable with ob_start() and ob_get_clean. The value set by ob_get_clean shows as a string, but when I try to cast it to an int in php, the value goes to 0.
It doesn't…

RoamingPro
- 11
- 3
1
vote
1 answer
ob_start difference between https and http?
Is there a different behaviour for ob_start, ob_end_flush, ob_end and ob_flush in https compared to http?
I have read the posts about difference between http and https:
Difference between http and https
Difference between HTTPS and SSL
as I have…

leopold
- 1,971
- 1
- 19
- 22
1
vote
1 answer
Add span inside anchor output using PHP's ob_get_contents function
What I have:
A PHP function that outputs a log in/out link based on whether the user is correspondingly logged in/out.
bar
What I need:
I need a span wrapped around the link text inside the anchor element.

Clarus Dignus
- 3,847
- 3
- 31
- 57
1
vote
1 answer
PHP - ob_start("ob_gzhandler") why the function not use directly in zend framework project?
I beginer in zend framework.
ob_start("ob_gzhandler") - why the function not use directly in zend framework project?
(does ob_start("ob_gzhandler") used auto in zend framework? )
Thanks

Ben
- 25,389
- 34
- 109
- 165