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 route model binding?
Explain the difference between laravel 4 and laravel 5?
What are string and array helpers functions in laravel?
What is validation in laravel and how it is used?
Explain automatic injection in laravel?
What are the difference between insert() and insertgetid() in laravel?
What is kernel in laravel?
what is meant by CSRF Protection in Laravel ?
How to use delete statement in laravel?
I just installed laravel and have the evil whoops error,how do I find out what’s wrong and fix it?
What is meant by Authorization Mechanism in Laravel ?
Explain the concept of encryption and decryption in laravel.
What are accessors and mutators in eloquent and why should you use them?
Is laravel built on symfony?
What is use keyword in laravel?