Download a library of downloadable code from a library?

Can I load a library from a library in a code igniter?

If i do

$this->validator = $this->CI->load->library('validators/'.$params['validator']);

from another library $ this-> validator is NULL.

Why should it be?

+3
source share
1 answer

Check out the signature of the CI_Loader class for the library () method that you reference:

/**
 * Class Loader
 *
 * This function lets users load and instantiate classes.
 * It is designed to be called from a user 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)
{

It returns void, so of course everything you set for the return value will be null. I think you are confused about the purpose of this method. Download it to the library and attach it to the codeigniter super object so you can reference it as:

$this->CI->[library name]

( , ) :

$this->CI->[newly loaded super awesome validator library]
+11

Source: https://habr.com/ru/post/1776984/


All Articles