• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I add outside code in codeigniter?

Hello everyone, I have an outside code or script, for example, including functions, classes inside even connecting database. Is there any way to add this code into codeigniter as class libraries or customized codes? Please explain more details if yes. Thanks much

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:

If your library contains a method named "display_page", call it like this:
PHP Code:

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:
Now, the functions are available.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.