更新时间:2023-11-19 17:56:52
查看CI_Loader类对您引用的library()方法的签名:
Check out the CI_Loader class's signature for the library() method you refer to:
/**
* Class Loader
*
* This function lets users load and instantiate classes.
* It is designed to be called from a user's app controllers.
*
* @access public
* @param string the name of the class
* @param mixed the optional parameters
* @param string an optional object name
* @return void
*/
function library($library = '', $params = NULL, $object_name = NULL)
{
它返回void,所以当然你设置的返回值为null。我想你对该方法的目的感到困惑。它加载库并将其附加到codeigniter超级对象,以便您可以引用它:
It returns void, so of course whatever you set the return value to will be null. I think you're confused about the purpose of that method. Its to load the library and attach it to the codeigniter super-object, so that you can reference it as:
$this->CI->[library name]
在您的情况下,到新加载的库(一些特定的验证器库,我基于你的代码片段猜测):
In your case, you'll just want to refer to the newly-loaded library (some specific validator library I'm guessing based on your code snippet) in the usual way:
$this->CI->[newly loaded super awesome validator library]