note 118883 added to function.header

From: Date: Mon, 22 Feb 2016 17:11:52 +0000
Subject: note 118883 added to function.header
Groups: php.notes 
Request: Send a blank email to php-notes+get-205010@lists.php.net to get a copy of this message
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. ---- Server IP: 72.52.91.14 Probable Submitter: 200.171.180.183 ---- Manual Page -- http://php.net/manual/en/function.header.php Edit -- https://master.php.net/note/edit/118883 Del: integrated -- https://master.php.net/note/delete/118883/integrated Del: useless -- https://master.php.net/note/delete/118883/useless Del: bad code -- https://master.php.net/note/delete/118883/bad+code Del: spam -- https://master.php.net/note/delete/118883/spam Del: non-english -- https://master.php.net/note/delete/118883/non-english Del: in docs -- https://master.php.net/note/delete/118883/in+docs Del: other reasons-- https://master.php.net/note/delete/118883 Reject -- https://master.php.net/note/reject/118883 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#205010) next »