Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel : Return text/html as response

In the laravel controller if someone wants to just send html as response and show it in the browser what is the best way to perform this action without any issue.

I want something like:

$html = "<html>-- All html document content --</html>"
// to show as html in browser.
return $html; 
like image 532
kshitij Avatar asked Nov 17 '25 05:11

kshitij


1 Answers

After some search I found a simple way, you can give any another way to perform this operation or if this is wrong way to do.

return response($html, 200)->header('Content-Type', 'text/html');

It worked on my machine. Kindly do give more suggestions

like image 190
kshitij Avatar answered Nov 19 '25 22:11

kshitij