Answer Posted / rachana devi
While building application it may be required to pass data to the views.
Pass an array to view helper function.
After passing an array, we can use the key to get the value of that key in the HTML file.
Example :
Observe the following example to understand more about passing data to views -
Copy the following code and save it at resources/views/test.php
<html>
<body>
<h1><?php echo $name; ?></h1>
</body>
</html>
Add the following line in app/Http/routes.php file to set the route for the above view.
app/Http/routes.php
Route::get('/test', function(){
return view('test',[‘name’=>’Virat Gandhi’]);
});
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is kernel in laravel?
What is a Artisan command ?
What service provider’s register method does?
How to start, stop mysql on valet?
What is laravel illuminate?
Tell me how to use insert statement in laravel?
What is design pattern in laravel?
Tell us how to use update statement in laravel?
What is localization?
What is faker in laravel?
What are laravel’s contracts?
How to get data between two dates with query in laravel?
What is php artisan. List out some artisan commands?
What is service container in laravel?
what is Blade ?