php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #75711 php.ini documentation fails to mention zend.assertions
Submitted: 2017-12-20 13:16 UTC Modified: -
From: mikko dot rantalainen at peda dot net Assigned:
Status: Open Package: Documentation problem
PHP Version: 7.0.26 OS: Ubuntu Linux 16.04 LTS
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
29 - 24 = ?
Subscribe to this entry?

 
 [2017-12-20 13:16 UTC] mikko dot rantalainen at peda dot net
Description:
------------
---
From manual page: http://www.php.net/info.configuration
---
...
assert.active boolean
Enable assert() evaluation.
...

This is no longer true. PHP 7 requires setting zend.assertions=1 in php.ini or assert() will never do nothing.

The above referenced runtime configuration should include following from http://php.net/assert:

PHP 7 configuration directives for assert()

Directive	Default value	Possible values

zend.assertions	(default 1)
1: generate and execute code (development mode)
0: generate code but jump around it at runtime
-1: do not generate code (production mode)

assert.exception (default 0)
1: throw when the assertion fails, either by throwing the object provided as the exception or by throwing a new AssertionError object if exception wasn't provided
0: use or generate a Throwable as described above, but only generate a warning based on that object rather than throwing it (compatible with PHP 5 behaviour)


Test script:
---------------
<?php ini_set("assert.active", 1); assert(false); ?>

or directly from command line:
php -d zend.assertions=-1  -r 'ini_set("assert.active", 1); assert(false);'
vs
php -d zend.assertions=1  -r 'ini_set("assert.active", 1); assert(false);'


Expected result:
----------------
Above test script should display a warning or uncatched exception about failed assert. Instead, with default PHP 7 configuration, nothing will happen.


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Dec 05 22:01:23 2019 UTC