I want to learn Zend Framework 2, I already install it in my machine, I reached the welcome page, that's good, so when I look it's structure it has a big difference in CodeIgniter or Laravel, my problem is I want to display some text or string in my index.phtml
. In my IndexController.php
I got this.
public function indexAction() {
$sample = 'sample string'; // this is what I want to pass in my index.phtml
return new ViewModel();
}
- How can I pass the variable into my
index.phtml
? - How can I display it in my
index.phtml
?
For example, in CodeIgniter look like this.
//Controller.php
public function indexAction() {
$data = 'Sample data'; // this is sample string that will display in my index.php
return view('home',$data);
}
//View
<?php
echo $data; // it will print the string in my $data(variable);
?>
I'm newbie in Zend Framework 2, I don't have any idea in this framework. help me guys.
Thank you in advance for helping mo to solve my problem.