• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
code Ignitor controller

#1
<?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?


Attached Files Thumbnail(s)
   
Reply

#2
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/argument1/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!
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.