note 118883 deleted from function.header by cmb
| From: | cmb@php.net | Date: | Mon, 22 Feb 2016 19:44:17 +0000 |
| Subject: | note 118883 deleted from function.header by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-205015@lists.php.net to get a copy of this message | ||
Note Submitter: somebody at somewhere dot com
----
Either I faced a rare bug or there is some undocumented thing about header(). It seems it cannot be
used within functions and may generate a HTTP 500 (tested with PHP 5.3.29).
I have tried something like this:
<?php
ob_start();
function accepted() {
header('Content-Length: 0');
header($_SERVER["SERVER_PROTOCOL"].' 202 Accepted');
}
// some more stuff that doesn't generate an output yet...
accepted();
// some more code here...
ob_end_flush();
?>
and as result I got a "Server Error" response. Putting the header() lines inline and out
of a function stopped the error.