Friday, June 8, 2012

Introduction to Codeigniter


Read The Indonesian Version
CodeIgniter is open source PHPFramework. It's free to use and manipulate as you wish. CodeIgniter uses MVC (Model View Controller) model programming. MVC is a programming concept where logic and layout are separated, so that the programmers and designers can do their job in focus. Codeigniter can download here.



Picture MVC model programming

Model Used to process the database in this case is the CRUD (Create, Read, Update, Delete)
Controller Class and / or function that will be called on the browser address bar and use to get query results from the model and then display it on the view
View Here is the WEB design area, here they are working enhance the data display query results, by adding the CSS and JS

For the begining let us give instance, how to create "Hello PHP" with controller and view.
Create a php file and rename it with c_hello.php, copy this following code
 
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class C_hello extends CI_Controller{
            
   function __construct(){
                
     parent:: __construct();
                
   }
            
   function index(){ 
     $data['hello'] = "Hello PHP";
     $this->load->view('v_hello',$data);
   }
}
?>
  
Second create view and named it with v_hello.php, copy this following code
 
<?= $hello; ?>
 

** GOOD LUCK **

0 comments

Post a Comment