-4

What does exactly the value of output_buffering ini variable mean in php.ini? On our older server, it was set to 1

output_buffering = 1

With this setting, I could call ob_clean(); and it worked like a charm. However, we moved our system to a new server where the output buffering was set to 4096:

output_buffering = 4096

With this, calling ob_clean(); did not have any effect, until I explicitly started the very beginning of my code with ob_start(); (It seems that on the other server with output_buffering=1 it was called implicitly).

ACs
  • 1,325
  • 2
  • 21
  • 39
  • `4096` is size of output that is buffered by default. – u_mulder Feb 11 '19 at 14:02
  • PD of [What is output buffering?](//stackoverflow.com/q/2832010) – mario Feb 11 '19 at 14:04
  • Your `php.ini`, the PHP Manual and the tag name `Output buffering` you added to your question will all supply you with lot's of information about Output buffering. – Peter Feb 11 '19 at 14:06
  • @Peter Okay maybe the title is misleading, but please read the question: you can see I was not actually asking what output buffering is, but why is the value 1 explicitly starts output buffering at the beginning of my script but with the value of 4096 I have to explicitly call ob_start(); – ACs Feb 11 '19 at 14:42
  • Possible duplicate of [What is output buffering?](https://stackoverflow.com/questions/2832010/what-is-output-buffering) – Dave Feb 11 '19 at 14:43
  • @Dave Please read the question – ACs Feb 11 '19 at 14:44
  • @mario please read the question – ACs Feb 11 '19 at 14:44
  • 1
    @ACs Please read the link, and the manual section contained therein. – mario Feb 11 '19 at 14:45
  • There is at least one answer in the duplicate link that explains things very clearly. – Dave Feb 11 '19 at 14:46
  • That is so easy to google, dear ACs. = 1 means simply 'On' with the default of the current version. 4096 is 'On' with a concrete value: http://php.net/manual/de/outcontrol.configuration.php#ini.output-buffering – iquellis Feb 11 '19 at 14:47

1 Answers1

7

output_buffering boolean/integer

You can enable output buffering for all files by setting this directive to 'On'. If you wish to limit the size of the buffer to a certain size - you can use a maximum number of bytes instead of 'On', as a value for this directive (e.g., output_buffering=4096). This directive is always Off in PHP-CLI.

From the PHP Manual

What this means is :

  • A value of 0 is false/off so output buffering is disabled.
  • A value of 1 is true/on so that output buffering is enabled and has no set limit (at least in this scope) to the maxmum buffer size.
  • A value of >1 is the maximum number of bytes for a custom output buffer size.

Therefore, choices above in the PHP.ini config are:

    output_buffering= 0 / 1 / 1+
Community
  • 1
  • 1
Martin
  • 22,212
  • 11
  • 70
  • 132