Welcome Guest, Not a member yet? Register   Sign In
How can I add outside code in codeigniter?
#2

It's possible to put use your existing code as a library in CodeIgniter. A library in CI is basically a class with one or more methods (functions) inside it.
You library goes into the application/libraries folder, and the file name must begin with a capital letter. E.g. Mylibrary.php

In order to use the library, load it from your controller:
PHP Code:
$this->load->library('mylibrary'); 

If your library contains a method named "display_page", call it like this:
PHP Code:
$this->mylibrary->display_page(); 

If your existing code is not in a class, but in procedural style, you can use it as a helper in CodeIgniter. Put the code in a file in the application/helpers folder. In order to access the functions inside the helper, call it like this:
PHP Code:
$this->load->helper('helperfile'); 
Now, the functions are available.
Reply


Messages In This Thread
RE: How can I add outside code in codeigniter? - by Wouter60 - 01-01-2016, 09:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB