php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71322 output before header() should give error
Submitted: 2016-01-09 21:42 UTC Modified: 2016-01-09 23:41 UTC
From: domains dot 30430573 at gmail dot com Assigned:
Status: Not a bug Package: Output Control
PHP Version: 7.0.2 OS: Windows 7 x64
Private report: No CVE-ID: None
 [2016-01-09 21:42 UTC] domains dot 30430573 at gmail dot com
Description:
------------
output before header() should give error, but no warning is shown and the header is actually sent (HTTP 403, in this case)

*NOTE* I am testing this with PHP 7.0.1 via XAMPP

Test script:
---------------
<?php
echo 'Some string';
header('HTTP/1.1 403 Forbidden');


Expected result:
----------------
PHP Warning:  Cannot modify header information - headers already sent by (output started at Z:\test\file.php:2) in Z:\test\file.php on line 3


Actual result:
--------------
HTTP 1.1 403 Forbidden
------------------------
Some string


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-01-09 23:27 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2016-01-09 23:27 UTC] requinix@php.net
Do you have output buffering enabled?
 [2016-01-09 23:38 UTC] domains dot 30430573 at gmail dot com
-Status: Feedback +Status: Open
 [2016-01-09 23:38 UTC] domains dot 30430573 at gmail dot com
output_buffering=4096

I just changed to output_buffering=Off and the script works as it should
 [2016-01-09 23:41 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2016-01-09 23:41 UTC] requinix@php.net
That would do it.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC