[eluser]jozeunico[/eluser]
Hello, well I have a couple of doubts about how to invoke this object let me show you :
I'm developing my own library (personal project) and I try to do this:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Moo{
var $CI = & get_instance(); ;
var $nombre = 'allende';
function __construct()
{
echo $this->nombre;
}
function showRegisterForm()
{
$this->CI->load->helper('moo_add');
//echo var_dump($CI);
return show_Register_Form();
}
}
?>
I understood that to user CI helpers, libraries, etc I need to get an instance (by reference) of CI super object using & get_instance();
But what I don't get it is Why I can't do it like above ? I mean:
The library is a class then I try to set the CI super object as a property of the library but, it doesn't work (like the property "$nombre".
I know that I can instance CI super-object inside a method and it works ver well, but my doubt it's Why I need to do it in a method? like this (even I tried at the __construct method and it works):
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Moo{
var $nombre = 'allende';
function __construct()
{
echo $this->nombre;
$this->CI =& get_instance();
}
function showRegisterForm()
{
$this->CI->load->helper('moo_add');
//echo var_dump($CI);
return show_Register_Form();
}
}
?>
Well any clue, link or information it'll be welcome, thanks everybody.