简体   繁体   中英

headers get sent even after output in php (laravel)

I am facing this problem for quite a while. Even if I output lots of thing before my headers, still my headers are being sent. NOTE: I have disabled output_buffering in my php.ini

View: ( headers.php )

<html>
<head>
<title> BLAH </title>
</head>

<body>
<p> TEXT </p>
<?php
    header("Pragma: no-cache");
    echo "something";
    header("Content-type: text/html");
?>
</body>
</html>

Route:

Route::get("header", function(){
    return View::make("headers"); 
});

The response is handled by Laravel 's Response class and this class sends the response back to the client/browser and Laravel sets the headers. In your example, you are returning the view and in your view whatever is present, the Laravel framework will render those and then the rendered output will be sent to the client/browser .

You asked about headers_list

Check on PHP manual about headers_list() :

headers_list — Returns a list of response headers sent (or ready to send)

Here X-Powered-By: PHP/5.4.12 is your PHP version and is a response header.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM