【发布时间】:2014-03-26 14:51:18
【问题描述】:
我在我的php.log 中看到了这一行:
PHP Fatal error: Class 'MyNamespace\InvalidArgumentException' not found in <file> on line X
第 X 行包含以下内容:
throw new InvalidArgumentException("Error");
它发生在页面重新加载时。首先,我将一些值放入表单中,单击提交并加载我的页面。我单击刷新页面(使用我的浏览器功能)重新加载页面,这就是我得到错误的地方。
也许当我刷新页面时,会执行不同的代码路径。但我仍然认为这是一个应该始终工作的原生 PHP 类,但在我的情况下它会引发错误。
我在 Windows 上使用 PHP、Apache2,最初是通过 Zend Studio IDE 套件安装的。
class description 本身并没有给我任何提示。为什么会抛出错误,我该如何解决?
更新*
我的代码是:
if (!isset($modelNumber)) //$modelNumber is NULL when I refresh
throw new InvalidArgumentException("Error");
所以每当我上这门课时,我都会收到这个错误。当我删除 isset 行并直接抛出类时,它总是给我错误。
【问题讨论】: