How to determine wether ob_start(); has been called already

后端 未结 4 1644
误落风尘
误落风尘 2021-02-19 05:42

I use output buffering for gzip compression and access to what was put out before in a PHP script:

if(!ob_start(\"ob_gzhandler\")) ob_start();

4条回答
  •  没有蜡笔的小新
    2021-02-19 06:43

    General:

    if (ob_get_status())  {
      // ob started
    }
    

    More specific

    $status = ob_get_status();
    if ($status['name']=='ob_gzhandler') {
     // ob named ob_gzhandler started
    }
    

提交回复
热议问题