一点小问题
时间:2008-01-11
来源:互联网
1.2.3. Other New Language FeaturesException handling.
PHP 5 adds the ability for the well-known TRy/throw/catch structured exception-handling paradigm. You are only allowed to throw objects that inherit from the Exception class:
注意这段中的example code第一个catch块,参数是$e,等到print的时候却是$obj->problem了。原文如是,翻译如是。虽然问题不大,但是很容易让新手产生误会。
另外,翻译到底算不算原创呢?
为什么国外的开源就那么彻底,而国内却做得如此的藏头露尾。《PHP5 POWER PROGRAMMING》可以免费的下载,《PHP5 权威编程》却要¥90RMB。
[ 本帖最后由 hosander 于 2008-1-12 15:30 编辑 ]
PHP 5 adds the ability for the well-known TRy/throw/catch structured exception-handling paradigm. You are only allowed to throw objects that inherit from the Exception class:
复制PHP内容到剪贴板
public $problem;
function __construct($problem) {
$this->problem = $problem;
}
}
try { ... throw new SQLException("Couldn't connect to database"); ...}
catch (SQLException $e) { print "Caught an SQLException with problem $obj->problem";}
catch (Exception $e) { print "Caught unrecognized exception";}
Currently for backward-compatibility purposes, most internal functions do not throw exceptions. However, new extensions make use of this capability, and you can use it in your own source code. Also, similar to the already existing set_error_handler(), you may use set_exception_handler() to catch an unhandled exception before the script terminates.PHP代码:
class SQLException extends Exception {public $problem;
function __construct($problem) {
$this->problem = $problem;
}
}
try { ... throw new SQLException("Couldn't connect to database"); ...}
catch (SQLException $e) { print "Caught an SQLException with problem $obj->problem";}
catch (Exception $e) { print "Caught unrecognized exception";}
注意这段中的example code第一个catch块,参数是$e,等到print的时候却是$obj->problem了。原文如是,翻译如是。虽然问题不大,但是很容易让新手产生误会。
另外,翻译到底算不算原创呢?
为什么国外的开源就那么彻底,而国内却做得如此的藏头露尾。《PHP5 POWER PROGRAMMING》可以免费的下载,《PHP5 权威编程》却要¥90RMB。
[ 本帖最后由 hosander 于 2008-1-12 15:30 编辑 ]
作者: eclanp 发布时间: 2008-01-11
这是一个问题,我已经记录下来了,另外我们会向原文出版社提出这个问题.
关于免费下载的问题,我向仁兄解释下,此书引入国内出版是需要跟原文的出版社购买中文版权的.所以出版社也有成本.
关于免费下载的问题,我向仁兄解释下,此书引入国内出版是需要跟原文的出版社购买中文版权的.所以出版社也有成本.
作者: hosander 发布时间: 2008-01-12
明白!纯属一时激动,谢谢。
正在努力学习OO,说实话,是真的很想要简老师的这本书。
正在努力学习OO,说实话,是真的很想要简老师的这本书。
作者: eclanp 发布时间: 2008-01-13
那就努力表现哦~~


作者: luzhou 发布时间: 2008-01-14
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28