ask9 Posted January 23, 2012 Share Posted January 23, 2012 :'( Still forgetting it. <?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 */ All I just is to make the $data array variable as public and works across all function inside the class. Where did I made wrong? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/255572-undefined-variable-basic-mistake-~sigh~/ Share on other sites More sharing options...
phpSensei Posted January 23, 2012 Share Posted January 23, 2012 The $data variable is defined outside of the class scope. Quote Link to comment https://forums.phpfreaks.com/topic/255572-undefined-variable-basic-mistake-~sigh~/#findComment-1310231 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.