I read some other posts here on stackoverflow about passing parms to a class library (for example, How to pass multiple parameters to a library in CodeIgniter?) and I also read the user manual under the libraries section.
What I'm wondering is if it's possible to pass parameters as individual variables and not as an array?
My class - which I want to use outside of my codeigniter solution- look like this:
<?php
class ABC
{
private $_hostname;
private $_password;
private $_username;
private $_connection;
private $_data;
private $_timeout;
private $_prompt;
public function __construct($hostname, $password, $username = "", $timeout = 10)
{
set_include_path(get_include_path() . PATH_SEPARATOR . '/var/www/phpseclib');
include('Net/SSH2.php');
$this->_hostname = $hostname;
$this->_password = $password;
$this->_username = $username;
} // __construct
public function connect()
{
}
public function dosomething()
{
}
I know I can do something like :
$params = array('_hostname' => $ip, '_password' => 'password', '_username' => '');
$this->load->library($classname,$params );
But I do not want to use arrays because this class will be reused by non CI solutions. I've tried reverting to using a standard include() statement. So the code looks like:
set_include_path(get_include_path() . PATH_SEPARATOR . 'var/www/myCIapp/application/libraries');
include_once('libraries/'.$classname.'.php');
But it's complaining saying that it cannot find the include file. The specific message is:
A PHP Error was encountered
Severity: Warning
Message: include_once() [function.include]: Failed opening 'libraries/HP5406_ssh.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear:var/www/myCIapp/application/libraries/')
Filename: models/ss_model.php
Line Number: 88
Any suggestions would be appreciated. Thanks for reading...
$abc=new ABC($var1, $var2, $var3, $var4);, not sure if I understood it already.