Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zend framework get a variable from the controller to view

I'm new to zend and OOP in general. I have a indexAction with a variable that I need to pass to the view. I've declared the variable as public and I thought I could then get the variable in the view using $this->variable but it doesn't work.

How do I pass a variable from indexAction to the view?

like image 518
jim smith Avatar asked Dec 05 '25 16:12

jim smith


1 Answers

Within indexAction, you need to assign it to the view instance. simply do:

$this->view->something = "foo";

and in your view:

<?php echo $this->something ?>
like image 137
karim79 Avatar answered Dec 08 '25 05:12

karim79



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!