How do PHP programs pass values between model, view, and controller pages? For example, if a controller had an array, how does it pass that to the view?
EDIT:
I struggled with this question myself. I had returned to php programming after nearly a decade. I ran into couple of issues deploying PHP MVC frameworks into an experimental server so I ended up building a simple MVC variant myself.
In my simple design (front) controller interacts with the Model to populate a payload object and passes it to the view. Each view is implemented in a separate PHP file so controller uses include, to "load" the desired view. The view then can access the data via the designated name ($dataId) for the payload object.
class Controller {
public $model;
...
public function display($viewId,$dataId,$data)
{
$url = $this->getViewURL($viewId);
$this->loadView($url,$dataId,$data);
}
public function getViewURL($key)
{
$url = 'view/list_view.php';
if($key == 'create')
{
$url = 'view/create_view.php';
}
else if($key == 'delete')
{
$url = 'view/delete_view.php';
}
return $url;
}
public function loadView($url,$variable_name, $data)
{
$$variable_name = $data;
include $url;
}
}