美文网首页
php 断言assert

php 断言assert

作者: sorry510 | 来源:发表于2019-12-08 18:40 被阅读0次
assert_options(ASSERT_ACTIVE, 1); //启用断言
assert_options(ASSERT_WARNING, 0); //不输出警告
assert_options(ASSERT_QUIET_EVAL, 1); //不关闭错误提示
assert_options(ASSERT_BAIL, 1); //终止运行
assert_options(ASSERT_CALLBACK, 'my_assert_handler'); //启用回调函数
function my_assert_handler($file, $line, $code)
{
    echo "<hr>Assertion Failed:File '$file'<br />Line '$line'<br />Code '$code'<br /><hr />";
}
 
assert('1==2');

相关文章

网友评论

      本文标题:php 断言assert

      本文链接:https://www.haomeiwen.com/subject/xplpoftx.html