The second method in controller doesn't work PHP MVC
183
I have problem .Second method in controller does not to work .Output :undefined variable item.
In construct method anything is work . I searched in google about this item but nothing found Please help me resolve this problem. Thanks advance.
Controller
require_once("model/Model.php");
class Controller
{
function __construct()
{
$image = array();
$image = Model::selectAll();
require_once("view/index.php");
}
public function actionCategory($param = 0)
{
$item = Model::selectByName($param);
require_once("view/index.php");
}
}
Model
class Model
{
static public function selectAll()
{
$names = array("jhon" , "Hilary" , "Steven, "Jake");
return $names;
}
static public function selectByName($param)
{
$param = strval($param);
$param = "Hilary";
return $param;
}
}
View
foreach($names as $key)
{
print($key);
}
print($item);