How to Passing Data to Views ?
Answer / 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 |
In which directory controllers are kept in laravel?
What is laravel trait?
What is csrf_field () in laravel?
How to get cookies in laravel?
What is dependency injection in laravel?
Tell me does laravel support php 7?
What is laravel elixir?
How to make a custom validation rule in laravel?
What is localization?
What is x-csrf-token , how it is different from csrf tokens?
What is remember token in laravel?
Do you know what is php artisan.