Welcome Guest, Not a member yet? Register   Sign In
$this->load->library and __construct
#11

[eluser]pistolPete[/eluser]
[quote author="GSV Sleeper Service" date="1236093696"]If it were a single string then you could only ever make constructors that accept a single parameter. By using an array you can pass an unlimited amount of parameters.[/quote]

I disagree.
Code:
function library($library = '', $params = NULL, $object_name = NULL)
{
        if ($library == '')
        {
            return FALSE;
        }

        if ( ! is_null($params) AND ! is_array($params))
        {
            $params = NULL;
        }
If the check ! is_array($params)) wasn't there, you could easily pass everthing to a library constructor: a string, an array, an object...
Because later on, the class is instantiated using:
Code:
// $config == $params from above
$CI->$classvar = new $name($config);


Messages In This Thread
$this->load->library and __construct - by El Forum - 09-08-2008, 09:23 AM
$this->load->library and __construct - by El Forum - 09-08-2008, 09:46 AM
$this->load->library and __construct - by El Forum - 09-08-2008, 09:50 AM
$this->load->library and __construct - by El Forum - 09-08-2008, 09:53 AM
$this->load->library and __construct - by El Forum - 09-08-2008, 10:36 AM
$this->load->library and __construct - by El Forum - 09-08-2008, 10:59 AM
$this->load->library and __construct - by El Forum - 09-08-2008, 01:49 PM
$this->load->library and __construct - by El Forum - 03-02-2009, 09:08 PM
$this->load->library and __construct - by El Forum - 03-02-2009, 11:03 PM
$this->load->library and __construct - by El Forum - 03-03-2009, 03:21 AM
$this->load->library and __construct - by El Forum - 03-03-2009, 04:32 AM
$this->load->library and __construct - by El Forum - 03-03-2009, 05:03 AM
$this->load->library and __construct - by El Forum - 03-03-2009, 06:24 AM
$this->load->library and __construct - by El Forum - 03-03-2009, 06:39 AM
$this->load->library and __construct - by El Forum - 03-03-2009, 06:51 AM
$this->load->library and __construct - by El Forum - 03-03-2009, 07:19 AM



Theme © iAndrew 2016 - Forum software by © MyBB