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

Description

assert.warning is a legacy INI directive that, when assert.exception is disabled, controls whether a failed assert() call emits an E_WARNING. It is part of the pre-PHP 7 assertion configuration that predates AssertionError.

Since this directive only has an effect together with the also-deprecated assert.exception, and there is no equivalent replacement to keep emitting a custom warning message, it is now deprecated as well. Once removed in PHP 9, disabling it will no longer be possible.

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

Example

<?php

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

?>

Alternatives

  • Rely on the AssertionError exception thrown by failed assertions instead of the legacy warning-based reporting.
  • Remove ini_set()/ini_get() calls involving assert.warning from the code.

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

Changed Behavior

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