PHP - How Detect if Output Buffering is Enabled

后端 未结 4 1101
轮回少年
轮回少年 2020-12-11 04:20

Is there a simple way to detect in PHP if output_buffering is enabled in php.ini? I\'d like to be able to display a message if it is not enabled.

Within my a

相关标签:
4条回答
  • 2020-12-11 04:27

    simple

    check by

    echo ini_get('output_buffering');
    

    or run a file calling phpinfo(); function it will list all veriables containing values check the value for 'output_buffering ' in list.

    0 讨论(0)
  • 2020-12-11 04:35

    You can access the output_buffering value in the php.ini file by doing:

    var_dump(ini_get('output_buffering'));
    

    But I think what you are looking for is ob_get_level() (or ob_get_status()):

    var_dump(ob_get_level());
    

    Returns the level of nested output buffering handlers or zero if output buffering is not active.

    0 讨论(0)
  • 2020-12-11 04:40

    You can check any INI setting in PHP with the ini_get method. http://php.net/ini_get

    ini_get('output_buffering');
    

    Likewise, you can change most INI settings with ini_set:

    ini_set('output_buffering', 'on');
    
    0 讨论(0)
  • 2020-12-11 04:52

    I think you can go

    if(!ob_start())
    {
    }
    
    0 讨论(0)
提交回复
热议问题