Re: Re: Crazy Serialize/Header/$_POST PHP Error - Is this a bug?
| From: | John Holmes | Date: | Tue, 24 Aug 2004 15:11:40 +0000 |
| Subject: | Re: Re: Crazy Serialize/Header/$_POST PHP Error - Is this a bug? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-194582@lists.php.net to get a copy of this message | ||
Exactly what part of this is confusing you?
When you first request the page, $_POST is empty, so you end up with a serialized value of "a:0:{}" which has a length of 6.
When you submit the form, you end up with a serialized value of:
a:1:{s:3:"foo";s:3:"bar";}
which has a length of 26. Maybe I missed something in this thread, but what's the issue here?
---John Holmes...
PS: Sorry for the top post but OE didn't include the > characters in the reply below for some reason and I'm too lazy to add them myself. :)
----- Original Message ----- From: "Peters, Eric" <ericp@amazon.com>
To: "Daniel Schierbeck" <dasch@ulmail.net>; <php-general@lists.php.net>; "Curt Zirzow" <php-general@zirzow.dyndns.org>
Sent: Tuesday, August 24, 2004 10:38 AM
Subject: RE: [PHP] Re: Crazy Serialize/Header/$_POST PHP Error - Is this a bug?
Check this out:
bash-2.05$ cat test.php
<?php
function jpcache_debug2($s2)
{
$length = strlen($s2);
$length++;
$headers = "X-CacheDebug-five: $length";
header($headers);
print $length . "\n";
print strlen($s2);
}
$myVariable = serialize($_POST);
jpcache_debug2($myVariable);
?>
<html>
<body>
<form method="POST" action="test.php" enc-type="multipart/form-data">
<input type="hidden" name="foo" value="bar">
<input type="submit" value="blah">
</form>
</body>
</html>
bash-2.05$
Response:
Date: Tue, 24 Aug 2004 14:35:55 GMT
Server: Apache/1.3.26 (Unix) mod_ssl/2.8.9 OpenSSL/0.9.6k PHP/4.3.3 mod_perl/1.26 mod_fastcgi/2.2.10
X-Powered-By: PHP/4.3.3
X-CacheDebug-five: 7
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html
27
26
<html>
<body>
<form method="POST" action="test.php" enc-type="multipart/form-data">
<input type="hidden" name="foo" value="bar">
<input type="submit" value="blah">
</form>
</body>
</html>
How the bloody hell is $length being treated differently?
Thanks,
Eric
-----Original Message-----
From: Daniel Schierbeck [mailto:dasch@ulmail.net]
Sent: Tuesday, August 24, 2004 4:53 AM
To: php-general@lists.php.net
Subject: [PHP] Re: Crazy Serialize/Header/$_POST PHP Error - Is this a bug?
Eric Peters wrote:
I think I've boiled my problem....for some reason I can't header() a serialized $_POST variable Running PHP 5.0 Final (and also tested with 4.3.3): -- begin file -- <?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> -- end file -- Response Headers - Begin output: Date: Mon, 23 Aug 2004 23:56:14 GMT Server: Apache/1.3.27 (Unix) (Red-Hat/Linux) PHP/5.0.0 mod_ssl/2.8.12 OpenSSL/0.9.6b X-Powered-By: PHP/5.0.0 X-CacheDebug-five: a:0:{} 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> Anyone know why my header() output behaves so funky? Thanks, EricTry to use unserialize(); -- Daniel Schierbeck -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php