CodeIgniter Forums
Problem with libraries - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: Problem with libraries (/thread-21588.html)



Problem with libraries - El Forum - 08-14-2009

[eluser]Unknown[/eluser]
Welcome and sorry for my poor english.
I have big problem with libraries.
I writed my own library:

Code:
class Log_in
{

    function Log_in()
    {
        echo $this->input->post('username');

    }

}
This library is loaded by autoload.php file.
When I run this class in controller, I receive this error:

Fatal error: Call to a member function post() on a non-object in...

Can you help me?


Problem with libraries - El Forum - 08-14-2009

[eluser]rogierb[/eluser]
$this is private in the library, it is not the CI superobject.

$CI =& get_instance();
$CI->input->post('username');

Check the userguide: http://ellislab.com/codeigniter/user-guide/general/creating_libraries.html


Problem with libraries - El Forum - 08-14-2009

[eluser]Unknown[/eluser]
Thank you rogierb.
It works!