[PHP] assert()断言检测函数

assert_options函数 设置断言的参数

assert 函数 ,检测一个断言

<?php
// 激活断言,并设置它为 quiet
assert_options(ASSERT_ACTIVE, 1);
assert_options(ASSERT_WARNING, 0);
assert_options(ASSERT_QUIET_EVAL, 1);


// 设置回调函数
assert_options(ASSERT_CALLBACK, 'my_assert_handler');

// 让一则断言失败
assert('mysql_query("")');


//创建处理函数
function my_assert_handler($file, $line, $code)
{
    echo "error:
        File '$file'
        Line '$line'
        Code '$code'";
}

  

猜你喜欢

转载自www.cnblogs.com/taoshihan/p/10531744.html