Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

assert.bail INI setting is deprecated

Description

assert.bail is a legacy INI directive from the pre-PHP 7 implementation of assert(). When enabled, it terminated script execution as soon as a failed assertion was encountered, instead of letting the script continue.

This behavior is redundant with throwing an AssertionError (the default behavior since PHP 7 when assert.exception is enabled), which already interrupts execution unless the exception is caught. As part of the general cleanup of the legacy assertion configuration, assert.bail is now deprecated.

The deprecation notice is triggered whenever assert.bail is set to a truthy value, either in php.ini or through ini_set().

Example

<?php

ini_set('assert.bail', '1');

?>

Alternatives

  • Rely on the AssertionError exception thrown by failed assertions (controlled by assert.exception) to stop execution, and catch it where appropriate.
  • Remove ini_set()/ini_get() calls involving assert.bail from the code.

In previous PHP versions, this error message used to be :ref:assert.active-ini-setting-is-deprecated. In more recent PHP versions, this error message is now :ref:assert.exception-ini-setting-is-deprecated.

Changed Behavior

This error may appear following an evolution in behavior, in previous versions. See assert