I know that this tread has long passed, but it was one of the questions that I met, looking for my answer. So here is my solution ...
This is PHP. Create your class as a library, load it using the standard CI loader class, but use it as in a regular PHP script.
Create your class:
class My_class { var $number; public function __construct($given_number){ $number = $given_number; } public function set_new_num($given_number){ $number = $given_number; } }
Download it:
// This will load the code so PHP can create an instance of the class $this->load->library('My_class');
Then create an instance and use the necessary object:
$num = new My_class(24); echo $num->number; // OUTPUT: 24 $num->set_new_num(12); echo $num->number; // OUTPUT: 12
The only time I use $ this-> my_class is to make calls to the static functions that I encode.
source share