code Ignitor controller |
<?php
class Pages extends CI_Controller { public function view($page = 'home') { if ( ! file_exists('application/views/pages/'.$page.'.php')) { // Whoops, we don't have a page for that! show_404(); } $data['title'] = ucfirst($page); // Capitalize the first letter $this->load->view('templates/header', $data); $this->load->view('pages/'.$page, $data); $this->load->view('templates/footer', $data); } } This is my controller code,how should i run my code?
Hi mohan. The functions in your controller are executed when you browse a URL that calls them. Suppose your CodeIgniter folder is called ci, and the URL to your application is http://localhost/ci. The function view in the controller Page will execute when you browse http://localhost/ci/page/view. If you browse http://localhost/ci/page/view/aboutus, the view function will receive 'aboutus' as its $page argument.
This is the general behavior -- http://localhost/ci/controller/function/.../argument2... I hope I understood your question, so please clarify if I didn't.
Hey, don't work without a PHP debugger. Several free IDEs have this features built in. Two are NetBeans and CodeLobster. Without a debugger, it's like you're driving with a blindfold on -- you are going to crash!
|
Welcome Guest, Not a member yet? Register Sign In |