fork download
  1. <?php
  2. class News extends CI_Controller {
  3.  
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->model('news_model');
  8. }
  9.  
  10. public function index()
  11. {
  12. $data['news'] = $this->news_model->get_news();
  13. $data['title'] = 'News archive';
  14. //breakpoint
  15. $fh = fopen("temp/breakpoint.html", 'w');
  16. fwrite($fh, "Try Break Point");
  17. fclose($fh);
  18. //
  19. $this->load->view('templates/header', $data);
  20. $this->load->view('news/index', $data);
  21. $this->load->view('templates/footer');
  22. }
  23.  
  24. public function view($slug)
  25. {
  26. $data['news_item'] = $this->news_model->get_news($slug);
  27.  
  28. if (empty($data['news_item']))
  29. {
  30. show_404();
  31. }
  32.  
  33. $data['title'] = $data['news_item']['title'];
  34. $this->load->view('templates/header', $data);
  35. $this->load->view('news/view', $data);
  36. $this->load->view('templates/footer');
  37. }
  38.  
  39. public function create()
  40. {
  41.  
  42. $this->load->helper('form');
  43. $this->load->library('form_validation');
  44. $data['title'] = 'Create a news item';
  45.  
  46. $this->form_validation->set_rules('title', '標題', 'required');
  47. $this->form_validation->set_rules('text', '內文', 'required');
  48.  
  49. if ($this->form_validation->run() === FALSE)
  50. {
  51. $this->load->view('templates/header', $data);
  52. $this->load->view('news/create');
  53. $this->load->view('templates/footer');
  54.  
  55. }
  56. else
  57. {
  58. $this->news_model->set_news();
  59. $this->load->view('news/success');
  60. }
  61. }
  62. }
  63. ?>
Runtime error #stdin #stdout #stderr 0.01s 20520KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Fatal error:  Class 'CI_Controller' not found in /home/L73opw/prog.php on line 2