php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34744 system() forces Content-type header output
Submitted: 2005-10-05 20:53 UTC Modified: 2005-10-06 02:21 UTC
From: clewis at myfonts dot com Assigned:
Status: Not a bug Package: Output Control
PHP Version: 5.0.5 OS: Windows XP, CentOS 4
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: clewis at myfonts dot com
New email:
PHP Version: OS:

 

 [2005-10-05 20:53 UTC] clewis at myfonts dot com
Description:
------------
Calling the system() function forces the standard Content-type: text/html header output, even when output buffering is on.  This behaviour is unlike other output commands such as print, which suppress the "automatic" headers until the output buffer is flushed.

Note that replacing system() with print() in the sample code works as expected.

Reproduce code:
---------------
<?php

ob_start();

chdir("/");
system("ls");

ob_end_clean();

header("Content-type: text/plain");
print "Hello  World.";

?>

Expected result:
----------------
Content-type: text/plain

Hello World.


Actual result:
--------------
Content-type: text/html

Warning: Cannot modify header information - headers already sent...
Hello World.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-05 21:37 UTC] sniper@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.



 [2005-10-05 22:06 UTC] clewis at myfonts dot com
I'm using Apache 2 APXS module on both Windows XP SP2 and CentOS 4.1 (like RHEL 4), if that helps.
 [2005-10-05 23:07 UTC] sniper@php.net
RTFM: "The system() call also tries to automatically flush the web server's output buffer after each line of output if PHP is running as a server module."

 [2005-10-06 02:21 UTC] clewis at myfonts dot com
christian dot mueller at dfpx dot de says:
-------
I read "web server's OB" ... that is quite different from the "php OB initiated with ob_start()" as reported in this Bug. 
-------

I (original submitter) say:

It looks like I should be using passthru() instead of system().  Nonetheless it is confusing that system() completely ignores the PHP output buffer.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 10:01:26 2024 UTC