CodeIgniter Forums
Message: Undefined variable: data - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Message: Undefined variable: data (/showthread.php?tid=48608)



Message: Undefined variable: data - El Forum - 01-22-2012

[eluser]solid9[/eluser]
All I just want is to declare the $data as public and as an array variable.
So that I can access it in every function of the class.
But it failed.

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$data = array();

class Main extends CI_Controller {

public function __construct() {
  parent::__construct();

  $this->load->helper('form');
  $this->load->helper('html');
  $this->load->helper('url');    
  $this->load->library('ion_auth');
  $this->load->library('session');
  $this->load->library('form_validation');
  $this->load->database();

  //$this->load->model('prod_m');
}


function login()
{
  $this->$data['header'] = $this->load->view('header', null, TRUE);
  
  $this->load->view('front_page', $this->data);
}

}
/* End of file main.php */
/* Location: ./application/controllers/main.php */

any help please.

Thanks in advanced


Message: Undefined variable: data - El Forum - 01-22-2012

[eluser]Jason Stanley[/eluser]
Quote:All I just want is to declare the $data as public and as an array variable.

Then do that?

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Main extends CI_Controller {

public $data = array();

public function __construct() {



Message: Undefined variable: data - El Forum - 01-23-2012

[eluser]solid9[/eluser]
@jason

sorry for this easy question,

My study on CodeIgniter is on and off.

Thanks for the help.