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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: domains dot 30430573 at gmail dot com
New email:
PHP Version: OS:

 

 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2022 The PHP Group
All rights reserved.
Last updated: Sat Aug 13 10:05:43 2022 UTC