Basic Steps To Learn About Codeigniter | Read It

Last time I talked about PHP and how to start moulding yourself into becoming a great PHP artist, Today I want to discuss PHP’s closest confidant and helper called Code-Ignitor
Code ignitor developed by British Columbia institute of technology was released in February 28, 2006.
It is an open source rapid development web framework which means code ingitor is really great at making
dynamic websites with php with high levels of quality, speed and efficiency
I mean when the PHP developer himself quotes Code ignitor as “a faster lighter and least like a framework” you
know it’s going to be good

How to start with basic code igniting

After installing code ignitor which works on the concept of MVC which stands for model-view-controller
which is a software approach where it separates application logic from presentation it allows the presentation
separated from the PHP Scripting  
One of the most important part of code ignitor is called a controller where it basically serves as an intermediary
between the model, the view and any other resources needed to process the HTML Request and end up in
generating a web page
What is a Controller in code ignitor

A controller is a simple class file which controls the whole application
To create your own controller you should first
First, go to application/controllers folder. You will find two files there, index.html and Welcome.php. These files come
with the CodeIgniter.
Keep these files as they are. Create a new file under the same path named “Test.php”.
Write the following code in that file
<?php
  class Test extends CI_Controller {
 
     public function index() {
        echo "hey man";
     }
  }
?>
Calling a Controller
The above controller can be called by URI as follows −
http://www.your-domain.com/index.php/test

Creating & Calling Constructor Method

Let us modify the above class and create another method named “hello”.
<?php
  class Test extends CI_Controller {  
     public function index() {
        echo "This is default function.";
     }
 
     public function hello() {
        echo "This is hello function.";
     }
  }
?>
We can execute the above controller in the following three ways −

Related: If you are looking for codeigniter tutorial then you may click here

Points to Remember


  • The name of the controller class must start with an uppercase letter.
  • The controller must be called with lowercase letter.
  • Do not use the same name of the method as your parent class, as it will override parent class’s functionality.

Comments

Popular posts from this blog

Laravel Application Structure

PHP Projects Free Download With Source Code

Best PHP Coaching Center in Noida