aid

Wednesday, 15 April 2015

Loading a View in MVC

Loading a View in MVC
To load a exacting view from your controller file you can use the following:
$this->load->view(‘viewname’);
In above syntex viewname’ is the name of your view file that is located in you application/view folder. please Note: The .php file extension must not need to be write.
Now, create a controller file in your application/controller folder mycontroller.php like this:
 <?php
class mycontroller extends CI_Controller {

          function index()
          {
                   $this->load->view(viewname’);
          }
}
?>
If you want to show your view from url. The URL is like this:

example.com/index.php/ mycontroller /

No comments:

Post a Comment