ob_start: Changed "erase" Argument to Integer "flags"

As of PHP 5.4.0, the erase boolean argument of the ob_start() function changed to a flags integer. Using a boolean with strict_types enabled will throw a TypeError. Without strict_types, the flag will evaluate to the wrong integer, thus causing incorrect behavior. Example:

declare(strict_types=1);

ob_start(null, 0, false);

Solution

declare(strict_types=1);

ob_start(null, 0, PHP_OUTPUT_HANDLER_STDFLAGS ^ PHP_OUTPUT_HANDLER_REMOVABLE);

Errors or Warnings

See Also