Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Php

Idiom #123 Assert condition

Verify that predicate isConsistent returns true, otherwise report assertion violation.
Explain if the assertion is executed even in production environment or not.

assert(_isConsistent);

isConsistent can be any PHP snippet without string quotes.

They will be evaluated only if `assert.active` PHP ini value is enabled, or `assert_options()` is called before.
#include <assert.h>
assert(isConsistent());

If NDEBUG is defined, the assert macro becomes void. Therefore, such expressions must not have side effects.

New implementation...
< >
programming-idioms.org