The view file is a web page, then the user is shown by the controllers. Such as header, footer, sidebar etc. We cannot call the views file directly. It is set from the controller to show which view file.
You can use the view function to load or display any view file.
echo view('home');
echo view('about');
echo view('service');
echo view('contact');
If you want to load multiple views file, then you cannot do that, these multiple files are interlinked.
echo view('header'); // header view file
echo view('menu'); // menu view file
echo view('content', $data); // content view file
echo view('footer'); // footer view file
echo view('home/login');
echo view('home/register');
echo view('users/dashboard');
We can pass the data as another parameter in the view function. Through this medium we pass the view file data from the controller.
$data = [
'title' => 'My title',
'heading' => 'My Heading',
'message' => 'My Message'
];
// data pass in view file
echo view('blogview', $data);
public function index()
{
$data['title'] = "My Real Title";
$data['heading'] = "My Real Heading";
// data pass in view file
echo view('blogview', $data);
}
// show heading in view file
<h1><?= $heading ?></h1>
My name is Deepak tailor as a fullstack developer. I have been in the IT industry (PHP, Nodejs, flutter) for the last 5 years. For professional and customize web development & app development, you can send inquiry on our email.
----
You can contact him at deepaktailor10@yahoo.in