Answer Posted / nafees ahmad
Laravel provides several different ways to return response.
Response can be sent either from route or from controller.
The basic response that can be sent is simple string as shown in the below sample code.
This string will be automatically converted to appropriate HTTP response.
Example :
Step 1 - Add the following code to app/Http/routes.php file.
app/Http/routes.php
Route::get('/basic_response', function () {
return 'Hai to One and All';
});
Step 2 - Visit the following URL to test the basic response.
http://localhost:8000/basic_response
Step 3 - The output will appear as shown in your screen.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is db facade?
How do you generate urls?
By default valet serve your app which tld? On how to configure it to use another domain?
How to use cookies in laravel?
How to create Controller Laravel - File Uploading ?
How to redirect user with flashed session data in laravel?
What is bearer token?
How to create custom library in laravel?
How to Passing Data to Views ?
How do you install laravel?
Explain how to get current url in laravel?
How will you explain guarded attribute in a laravel model?
What is the use of the bootstrap directory?
Name aggregates methods of query builder.
What are Uses While Using the properties of Request instance ?