PHP 5.4.10版中PHP对异常的态度是否变化?
发布时间:2020-12-13 13:13:02 所属栏目:PHP教程 来源:网络整理
导读:以下内容可以在 PHP 5.3中使用,但不适用于 PHP 5.4.10. throw new Custom_Exception();class Custom_Exception extends Exception {} PHP 5.4.10将回复以下致命错误: Class ‘Custom_Exception’ not found in … 有人知道为什么吗 附:在throw语句上面移动
以下内容可以在
PHP 5.3中使用,但不适用于
PHP 5.4.10.
throw new Custom_Exception(); class Custom_Exception extends Exception {} PHP 5.4.10将回复以下致命错误:
有人知道为什么吗 附:在throw语句上面移动类定义修复它.
我把你的代码放在一个名为test.php的文件中,并下载了
php-5.4.10
当我执行: php -c php.ini-development -f test.php 我看到以下输出: PHP Fatal error: Uncaught exception 'Custom_Exception' in test.php:3 Stack trace: #0 {main} thrown in test.php on line 3 Fatal error: Uncaught exception 'Custom_Exception' in test.php:3 Stack trace: #0 {main} thrown in test.php on line 3 我相信你有一个配置问题.你是从命令行进行测试吗? 编辑: 我还比较了这两个版本的zend_compile.c中的do_bind_inherited_class. zend_compile.c from 5.3 zend_compile.c from 5.4.10 看起来他们只添加了对特征的支持. 我的答案是:不,我不相信态度有所改变. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |