PHP 7 - Expectations
Expectation allows for zero-cost assertions in production code, and provides the ability to throw custom exceptions when the assertion fails.
The PHP 7 Configuration directives for assert() are:
- 0 − generate code but skip around it at runtime
- -1 − in this mode not generate code
- 1 − generate and execute code
- 1 − throw
the default value is 0.
only generates a warning based on that object rather than throwing it just like PHP 5.
assertion :- In the PHP 7 returns a value, which will be executed and the result is used to indicate whether the assertion succeeded or failed
description : - If the assertion fails. it will be show failure message.
exception: the assertion fails and the assert.exception configuration directive is enabled.