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
Explain how to register a middleware in laravel?
What is csrf_field () in laravel?
Who are Manually Authenticating Users in Laravel ?
What is a laravel controller?
What are named routes in laravel?
What is lts in laravel?
Tell me how do I see all of the routes that are defined?
What is database migration in laravel?
How to create real time sitemap.xml file in laravel?
Tell me does laravel support php 7?
How to share data with views?
What are laravel contract’s?
What are the advantages of queue?
What is database migration in laravel? How to use this?
Explain collections in laravel.