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.exception INI setting is deprecated

Description

assert.exception controls whether a failed assert() throws an AssertionError (the default since PHP 7) or falls back to the legacy behavior of emitting a warning and continuing execution.

Disabling exceptions for assertions revives pre-PHP 7 behavior that is inconsistent with the rest of the language, where failures are normally reported through exceptions or errors. As part of the cleanup of the legacy assert.* configuration, this directive is now deprecated.

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

Example

<?php

ini_set('assert.exception', '0');

?>

Alternatives

  • Keep assert.exception enabled (the default) and catch AssertionError where a failed assertion needs to be handled instead of propagating.
  • Remove ini_set()/ini_get() calls involving assert.exception from the code.

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

Changed Behavior

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