require_once()或die()无法正常工作 [英] require_once () or die() not working
问题描述
有人知道为什么我的require_once()或die()吗?不管用.总是显示致命错误,而不是我输入die()的错误消息.参见下面的代码:
Does anyone know why my require_once () or die(); is not working. It's always shown the Fatal error instead of the error message that I key in into the die(). See below for my code:
require_once ('abc.php') or die("oops");
错误消息显示如下
致命错误:controller :: require_once()[function.require]:无法打开所需的'1'(include_path ='....."
"Fatal error: controller::require_once() [function.require]: Failed opening required '1' (include_path='....."
我键入的是
而不是消息(糟糕" ).
推荐答案
或的优先级高于require/require_once.因此php评估
or has a higher precedence than require/require_once. Therefore php evaluates
('abc.php') or die("oops")
,然后将结果传递给require_once. Or 接受两个布尔操作数. ('abc.php')计算为 true ,因此整个表达式为 true 和
before passing the result to require_once. Or takes two boolean operands. ('abc.php') evaluates to true therefore the whole expression is true and
require_once true;
被调用. require_once接受一个字符串,bool(true)-> string => 1 =>
is invoked. require_once takes a string, bool(true)->string => 1 =>
打开失败需要' 1 '
您不需要在那里的or die(...).如果无法读取该文件,则require_once仍将停止php实例.
You don't need the or die(...) there. If the file can't be read require_once will stop the php instance anyway.
这篇关于require_once()或die()无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!