1.6. Zend::exception()

Lazy loads an exception class, instantiates the exception, and returns it. 延迟加载(lazy load)一个异常类,实例化并返回对象实例。

<?php

Zend::exception($class, $message, $code);

?>

The $class argument specifies the exception class to load and instantiate, and is loaded using 第 1.3 节 “Zend::loadClass()”; as such, it must follow the framework class naming conventions and be somewhere in the PHP include_path. $class参数指定了要加载和实例化的异常类(这个类通过Zend::loadClass()来加载,见第 1.3 节 “Zend::loadClass()”)。本参数的命名一定要遵循命名规则,类文件可以位于include_path指定的位置。

$message$code参数都是可选的,将作为参数传递给异常类的构造方法。

如果加载成功,本方法会加载exception类,把$message$code参数传递给异常类的构造方法,然后创建一个实例并返回。如果无法加载类,或者该类不是Exception的子类,则抛出一个异常。