• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why doesn't destructor load views?

#1
[eluser]behnampmdg3[/eluser]
Hello;

Why cant I load views with destructor?

Thanks
Code:
class Members extends CI_Controller {
public $member_id;
public $email;
public function __construct()
  {
   parent::__construct();
   $data['title'] = "Members Page";
   $this->load->vars($data);
   $this->members();
   $this->places();
  }
public function index()
  {
  
  }
public function members()
  {
   $this->load->model('members_model');
   $data['members'] = $this->members_model->get_all_members();
   $this->load->helper('url');
   $this->load->vars($data);
  }
  
public function places()
  {
   $this->load->model('places_model');
    $data['places'] = $this->places_model->get_all_places();
    $this->load->vars($data);
    //$this->output->enable_profiler(TRUE);
   }
  
  public function send_email()
   {
    if(isset($_POST['email']))
      {
       $this->email = $_POST['email'];
      }
    $this->load->library('form_validation');
    $this->form_validation->set_rules('email','email','required');
   $this->load->helper('email');
    if (valid_email($this->email))
     {
      $this->do_send();
     }
    else
     {
      $this->show_error();
     }
   }
  public function do_send()
   {
    $email_valid = true;
    send_email($this->email, 'From Codeigniters engine', 'YAY');
    $data['form_message'] = "Email has been sent successfully";
    $this->load->vars($data);
   }
  public function show_error()
   {
    $data['form_message'] = "Invalid Email Address";
    $this->load->vars($data);
   }
  
  public function view()
   {
    $this->load->view('header_view');
    $this->load->view('members_view');
    $this->load->view('footer_view');
   }
  
  public function __destruct()
   {
    $this->view();
   }
  
  
}

#2
[eluser]solid9[/eluser]
_destructor is just the opposite of _constructor

http://php.net/manual/en/language.oop5.decon.php

study PHP first.

#3
[eluser]solid9[/eluser]
Also view is a CodeIgniter reserved word.
Better use another word.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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