Welcome Guest, Not a member yet? Register   Sign In
How to add your Class at CodeIgniter
#1

[eluser]BD-CI-Programmer[/eluser]
Step#1: create your own class
Code:
<?
class class_name {

function function_name()
{
echo “I am There”;
}

}
?>

Now save this file on your libraries (system->libraries) and file name is must according to your class name like class_name.php

Step#2: create a controller like this…


Code:
<?php
class own_controller extends Controller {

function own_controller()

{

parent::Controller();

}

function show_text()

{
$this->load->library(class_name);
echo $this-> class_name -> function_name();
}

}
?>

Now save the controller at your controller folder.

OUT PUT will be “I am There”
#2

[eluser]frenzal[/eluser]
excellent tip!


Smile
#3

[eluser]webthink[/eluser]
I had a sarcastic reply all typed out but my conscience got the better of me. I'm growing up.

Instead I'll offer this:
http://ellislab.com/codeigniter/user-gui...aries.html

and a tip:
Best to save to application/libraries rather than system/libraries
#4

[eluser]wiredesignz[/eluser]
Wow, thanks for the tutorial. Tongue
#5

[eluser]GSV Sleeper Service[/eluser]
*blank look*
#6

[eluser]webthink[/eluser]
*stares*
*blinks intermittently*
*stares more*
#7

[eluser]wiredesignz[/eluser]
This will probably go down in CI history as the most stupid thread. :lol:
#8

[eluser]Edemilson Lima[/eluser]
Quote:Now save this file on your libraries (system->libraries)

Nice way to mess with your CI installation! =P
#9

[eluser]xwero[/eluser]
Give this guy some credit not asking how to add your own library. He tried to help others, that is a plus in my book.

Edemilson Lima adding libraries to the system/libraries directory has some benefits for instance you can extend your library using the MY_ prefix.
#10

[eluser]Derek Allard[/eluser]
BD-CI-Programmer, I'd like to thank you for posting. Everything we post seems obvious to part of the community, and it very helpful to others. Thanks for taking the time to write this up, I assure you seeing it has helped someone. Some nice tips also in this thread, thanks all.




Theme © iAndrew 2016 - Forum software by © MyBB