PHP5的异常处理机制[5]--PHP5之前的错误处理--使用PEAR处理错误

类别:编程语言 点击:0 评论:0 推荐:

()使用PEAR处理错误

你也可以使用PEAR来处理错误。当发生错误,将返回一个 Pear_Error对象。后面的代码通过一个静态方法PEAR::isError()来检验这个对象。如果错误确实发生了,那么返回的Pear_Error对象将提供你需要的所有相关信息:

PEAR::getMessage()

- the error message 出错信息

PEAR::getType()

- the Pear_Error subtype 错误类型

PEAR::getUserInfo()

- additional information about the error or its context 附加信息

PEAR::getCode()

- the error code (if any) 出错代码


这里我们修改了getCommandObject()方法,使之返回一个Pear_Error对象。

index_pear.php

本文地址:http://com.8s8s.com/it/it28029.htm