assert

PHP 4, PHP 5, PHP 7, PHP 8
assert - Checks if assertion is false
Manual
Code Examples

Example #1 Using a custom handler to print a description

Result: Assertion failed at test.php:21: 2 < 1 Assertion failed at test.php:22: 2 < 1: Two is less than one
PHP Version:

Example #2 Handle a failed assertion with a custom handler

PHP Version:

Example #3 Expectations without a custom exception

Result: Hi!
PHP Version:

Example #4 Expectations with a custom exception

Result: Hi!
PHP Version:


Function assert:

PHP Options and Information Functions

Most used PHP functions