Reputation: 1367
I'm attempting to get all HTTP header output from a PHP file, when run via php-cgi. From everything I've read, php-cgi is supposed to output all headers by default. (There's even an option to suppress this, as though it happens automatically.)
I have a PHP file named "test.php", with the following contents:
header('Location: http://stackoverflow.com');
echo 'test';
But when I run it:
php-cgi -f test.php
The output is simply:
test
I expected the location header to be output first. How can I get this header info? I'm using PHP 5.5.3-1ubuntu2.3 (cgi-fcgi).
Upvotes: 0
Views: 913
Reputation: 1367
I got it! I noticed in the doc definition for the -f argument that it "Implies '-q'".
So this is the solution:
php-cgi test.php
(Without the -f argument)
Upvotes: 2
Reputation: 481
The problem is that you are not exiting the script once setting header. You would need to do something more like this
header('Location: http://stackoverflow.com');
exit();
otherwise code after the header() will be run aswell
Upvotes: -1