荆轲刺秦王
halt 是抛出异常,告诉你发生错误的文件名,第几行,给程序员看的。
$this->error是给用户看的,比如登陆时密码不正确就用$this->error .
重点说一下 halt :
说明:调试变量输出后中止程序的执行
示例:
$memberModel = Model('Demo');
$memberList = $memberModel -> memberList();
halt($memberList);
echo '这里的信息是看不到的';
输出:
array (size=4)
0 =>
array (size=3)
'id' => int 0
'name' => string 'thinkphp' (length=8)
'score' => int 1
1 =>
array (size=3)
'id' => int 4
'name' => string 'zhangsan4' (length=9)
'score' => int 0
2 =>
array (size=3)
'id' => int 5
'name' => string 'zhangsan5' (length=9)
'score' => int 0
3 =>
array (size=3)
'id' => int 6
'name' => string 'zhangsan6' (length=9)
'score' => int 0
需要注意的是:如果要使用 halt 做断电测试的话,需要先打开全局配置文件中的调试模式: 把app_debug改成 true