Welcome Guest, Not a member yet? Register   Sign In
create my own library with php 4 and get_instance
#1

[eluser]ariok[/eluser]
Hi all!
I read up on creating library in user documentation
and about the get_instance() function i founded this :

Quote:Also, please note: If you are running PHP 4 it's usually best to avoid calling get_instance() from within your class constructors. PHP 4 has trouble referencing the CI super object within application constructors since objects do not exist until the class is fully instantiated.

so.. if i need to use helper in my library what i have to do?? where i have to define the CI object reference ??

Thank you for your help
#2

[eluser]Armchair Samurai[/eluser]
Call get_instance() from your functions when you need it:
Code:
class Foo {

   function Foo()
   {
      /* get_instance() not here */
   }

   function bar()
   {
      $ci =& get_instance();

      $ci->load->helper('helpername');
   }

}




Theme © iAndrew 2016 - Forum software by © MyBB