Recently, with the PHP+codeigniter Framework, the framework is very light and quick to use.
First of all, how to define your own helper, personal understanding of helper is actually defined function method.
If you want to build a brand-new helper, as long as you create a PHP file in the application/helpers, the name is required, helpername_helper.php, the suffix must follow _helper when defining the name.
For example, if you want to build a helper named Goheaven, the name of the file is goheaven_helper.php. Quoting is also simple, $this->load->helper (' Goheaven '), and then you can use the function method in helper.
If you want to extend the CodeIgniter of the first existing helper, such as you want to expand the array, the name will be used My_array_ Helper.php, so that when you reference the helper of array again, you will automatically call the array you have defined.
Where the my_ prefix, in fact, can be modified according to their preferences, to config.php find $config[' subclass_prefix '] = ' my_ ' modified on it.
Again, how to define your own library, personal understanding of the library is actually defined class.
If you want to build a brand-new helper, just create a php file in Application/libraries, the name is required, libraryname.php, the first letter must be capitalized. For example, if you want to build a library called Goheaven, the name of the file is goheaven.php. The class name must match the Goheaven of the file name. The quote is also simple, $this->load->libraries (' Goheaven ').
If you want to extend the CodeIgniter of the original library, such as you want to expand the email, the name will be used my_email.php, so when you reference the library of email, you will automatically call your definition of email. The class name should be class My_email extends Ci_email.
If you want the helper and library to be automatically called, add it to application/config/autoload.php.
Another important point to make is that if you want to refer to CodeIgniter methods and classes in your custom helper and library, first of all, $CI =& get_instance (), equivalent to the usual $this, $CI->load-> Helper (' url ') = $this->load->helper (' url ');
In fact, there is a core Class, in fact, and the library of the same truth, it is no longer a further explanation
"Go" codeigniter define your own helper and helper methods