Cannot access view variables!

Hi All,

I am new to Yii framework, here is this basic but still confusing problem. Following is my code snippet.

In my controller script:




public function actionHelloWorld()

	{

		

		$this->render('helloWorld',array('var'=>'this is me'));

	}



In the corresponding view:




<h1>Hello, World!</h1>

<h3><?php echo $var; ?></h3>



However, in the output, only <h1> gets printed out, looks like $var is unaccessible in the view. Any suggestion? Many thanks in advance!

I can’t see anything wrong with your code, it should work as expected. Try


<?php print_r(get_defined_vars()) ?>

in the view to make debugging easier.