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 stack channel?
What is composer tool?
How can I install laravel in windows?
Does wordpress use laravel?
Explain php artisan?
How do I register an artisan command?
What is auth? How is it used?
How many types of middleware are there in laravel?
What are the steps Redirecting to Named Routes in Laravel ?
What are accessors and mutators in eloquent and why should you use them?
What is csrf protection in laravel?
Tell me how to get current environment in laravel 5?
What is map function in laravel?
How do I disable csrf protection in laravel?
Explain events in laravel?