Welcome Guest, Not a member yet? Register   Sign In
diectly use the controller's varibales in the view instead of the load vars in the view page, how bad?
#1

[eluser]searain[/eluser]
//controllers/home.php

class Home extends CI_Controller {

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


$this->test = "test again!";


}

// Home page for mobile website
function index(){
this->load->view('hometest')

//$data['test'] = $this->test;
//$this->load->view('hometest', $data);


}

}

//views/hometest.php
<?php
echo $this->test;
//echo $test;

?>

usually like the manual, we load the $this->test into $data, and we load the data in the view, and in the view, we use $test.

But instead of doing the above, we can also directly call the $this->test in the view page. I know it is not good. But is it really that bad or it is OK because codeigniter still allows it? Or is it there because CodeIgniter has no better way to disallow it?

Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB