php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29820 Variable is treated differently in header() vs print()
Submitted: 2004-08-24 17:00 UTC Modified: 2004-08-24 18:03 UTC
From: ericp at amazon dot com Assigned:
Status: Not a bug Package: Variables related
PHP Version: 5.0.1 OS: Linux 2.4.21-2.3a i686
Private report: No CVE-ID: None
 [2004-08-24 17:00 UTC] ericp at amazon dot com
Description:
------------
If I include a serialized variable in header() it produces an entirely different result than if I just print() the result...

I've also tested: 4.3.3, 5.0.0 and of course 5.0.1 and its reproducable in both scenario

Make sure you POST the form to get the variable back :)

even a strlen($s) will produce different results...its weird.

Thanks,

Eric

Reproduce code:
---------------
<?php
    function jpcache_debug2($s)
    {
         header("X-CacheDebug-five: $s");
                 print $s;
        }
        $myVariable = serialize($_POST);
        jpcache_debug2($myVariable);

?>
<html><body>
<form method="POST" action="test-error.php">
<input type="hidden" name="foo" value="bar">
<input type="submit" value="blah">
</form>
</body>
</html>bash-2.05$

Expected result:
----------------
Response Headers 

Date: Tue, 24 Aug 2004 14:49:52 GMT
Server: Apache/1.3.27 (Unix)  (Red-Hat/Linux) PHP/5.0.1 mod_ssl/2.8.12 OpenSSL/0.9.6b
X-Powered-By: PHP/5.0.1
X-CacheDebug-five: a:1:{s:3:"foo";s:3:"bar";}
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html

a:1:{s:3:"foo";s:3:"bar";}
<html>
<body>

<form method="POST" action="test-error.php">
<input type="hidden" name="foo" value="bar">
<input type="submit" value="blah">
</form>
</body>
</html>

Actual result:
--------------
Response Headers 

Date: Tue, 24 Aug 2004 14:49:52 GMT
Server: Apache/1.3.27 (Unix)  (Red-Hat/Linux) PHP/5.0.1 mod_ssl/2.8.12 OpenSSL/0.9.6b
X-Powered-By: PHP/5.0.1
X-CacheDebug-five: a:0:{}   <--- WHAT?!?
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html

a:1:{s:3:"foo";s:3:"bar";}
<html>
<body>

<form method="POST" action="test-error.php">
<input type="hidden" name="foo" value="bar">
<input type="submit" value="blah">
</form>
</body>
</html>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-24 18:03 UTC] ericp at amazon dot com
It was a problem in Mozilla's Developer Tools...It reruns the query to get the response headers ...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 30 22:01:31 2024 UTC