在Codeigniter中动态加载库

I'm try to load and call some methods dicamicaly libraries in Codeigniter like

$plugins = array('paypal', 'captcha');
foreach($plugins as $plugin){
    $this->load->library($plugin);
    //The problem appear when I'm try to call some method...
    echo $this->[$plugin]->hello_world();
}

Try loading it in the autoload.php file of CI

You can easily do it by following code. for more you can visit Codeigniter documentation

$this->load->library($plugin,null,'object_name');
$this->object_name->hello_world();

for remove instance of $this->object_name. better explanation here

unset($this->object_name);

or

$this->object_name = null;