【发布时间】:2016-10-19 11:18:06
【问题描述】:
就像 assert 甚至没有被调用一样。我很困惑。
版本
php -v
PHP 7.0.11-1+deb.sury.org~xenial+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.11-1+deb.sury.org~xenial+1, Copyright (c) 1999-2016, by Zend Technologies
脚本:
x.php
<?php
print ("Hello\n");
assert_options(ASSERT_ACTIVE,true);
assert_options(ASSERT_BAIL,true);
assert(false);
assert(true);
print ("Bye\n");
当我运行它时
php x.php
Hello
Bye
我原以为程序会因异常而终止。我要疯了吗?
【问题讨论】:
-
在 PHP7.0.12 我得到一个
Warning: assert(): assert(false) failed -
断言在 PHP7 检查 the manual987654321@ 中有所改变
-
我升级到 7.0.12 但输出是一样的。
codephp -v PHP 7.0.12-1+deb.sury.org~xenial+1 (cli) ( NTS ) 版权所有 (c) 1997-2016 The PHP Group Zend Engine v3.0.0, 版权所有 (c) 1998- 2016 Zend Technologies with Zend OPcache v7.0.12-1+deb.sury.org~xenial+1, 版权所有 (c) 1999-2016, by Zend Technologies :~/code/x/test$ php x.php Hello Bye跨度> -
然后检查您在
php.ini中设置的参数(手册中都提到过)