note 93526 rejected from function.system by danbrown
| From: | danbrown@php.net | Date: | Mon, 14 Sep 2009 16:55:54 +0000 |
| Subject: | note 93526 rejected from function.system by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-160551@lists.php.net to get a copy of this message | ||
Note Submitter: malte dot riesch at gmx dot net
----
This might be a bug, but be aware that the system function, at least on PHP 5.2 on Linux, disrupts
the output buffering process:
Consider something along the lines of:
<?php
ob_start();
system('pwd');
header("location: http://news.bbc.co.uk");
ob_end_clean();
?>
This will not redirect to the bbc site as it seems an (invisible) output has already been written
even though it was supposed to be captured. Consider using another function like exec() instead as a
workaround as replacing system('pwd') with echo exec('pwd') will work as
expected.