Assert is not working in PHP. So simple. What am I doing wrong? Assert is not working in PHP. So simple. What am I doing wrong? php php

Assert is not working in PHP. So simple. What am I doing wrong?


It looks like assertions are OFF out of the box on 7.0. In my php.ini file zend.assertions was set to -1, which means they are ignored. I have changed the setting to 1.

[Assertion]; Switch whether to compile assertions at all (to have no overhead at run-time); -1: Do not compile at all;  0: Jump over assertion at run-time;  1: Execute assertions; Changing from or to a negative value is only possible in php.ini! (For turning assertions on and off at run-time, see assert.active, when zend.assertions = 1); Default Value: 1; Development Value: 1; Production Value: -1; http://php.net/zend.assertionszend.assertions = 1

The script now works as expected.

php x.phpHelloPHP Warning:  assert(): assert(false) failed in /home/ubuntu/code/x/test/x.php on line 8