Welcome Guest, Not a member yet? Register   Sign In
How to initialize the constructor within the PEAR library
#1

[eluser]webbymonk[/eluser]
Hi guys, how are you guys?

I just tried the pear integration within CI. And i found some difficulties to initialize th e parameter within the constructor.

If we load the CI library, we have $params to pass through the library.
for ex: $this->load->library('library',$params);

as in the http://codeigniter.com/wiki/PEAR_integration/

in the example;
$http_request = $this->pearloader->load('HTTP','Request');

how initialize the class constructor that contains some parameter?

usually we do in the PHP
Code:
$serializer = new XML_Serializer(array(
                'rootName' => $this->_rootName,
                'indent' => "\t",
                'mode' => 'simplexml',
                'prependAttributes' => '_',
                'parseAttributes' => true
            ));

Thanks...
#2

[eluser]pistolPete[/eluser]
[quote author="webbymonk" date="1234955741"]
how initialize the class constructor that contains some parameter?
[/quote]
The second paramater is used to pass parameters to the constructor, but it has to be an array (as of CI 1.7):
Code:
$this->load->library('library_name',array('key2'=>'value1', 'key2'=>'value2');
Just have a look at the user guide: http://ellislab.com/codeigniter/user-gui...oader.html

Quote:usually we do in the PHP...
Since CI is PHP, you can do the exact same thing.
Use require and new if you don't want to use the Loader Class.
#3

[eluser]webbymonk[/eluser]
Thanks for your kindly response. I figured it out actually there is a third parameter also in the PEAR Integration library. I just found it, and also has to be array...




Theme © iAndrew 2016 - Forum software by © MyBB