php - Failure when passing a variable to a view CodeIgniter -


i trying pass $variable codeigniter controller view it's fail.

my controller code is:

class index_controller extends ci_controller {     public function index(){         $formurl = base_url().index_page().'authorization_controller/authorization';         $attributes = array('class' => 'authorization','id' => 'authorization');         $this->load->view('header');         $this->load->view('leftframe', $formurl, $attributes);         $this->load->view('rightframe');         $this->load->view('index');         $this->load->view('footer');     } } 

my view code is:

<?php echo form_open($formurl, $attributes); ?> </form> 

error message:

a php error encountered severity: notice message: undefined variable: formurl 

and

a php error encountered severity: notice message: undefined variable: attributes 

you need pass data in array or object. can access data referencing variable of same name array key in view. can achieve this:

public function index() {     $formurl = base_url().index_page().'authorization_controller/authorization';     $attributes = array('class' => 'authorization','id' => 'authorization');      // data pass view     $view_data['formurl'] = $formurl;     $view_data['attributes'] = $attributes;      $this->load->view('header');     $this->load->view('leftframe', $view_data);     $this->load->view('rightframe');     $this->load->view('index');     $this->load->view('footer'); } 

Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -