You have to look at the headers Exactly...submit the form and the HEADER version of the string returns "a:0:{}"
But, a print() of the same string variable correctly returns "a:1:{s:3:"foo";s:3:"bar";}" Dig deeper into it :) I had to use the Developer tools plugin in Firefox to get the HTTP Headers that were returned :) Compare those two, and boggle the mind ;) Thanks! Eric -----Original Message----- From: John Holmes [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 24, 2004 8:12 AM To: Peters, Eric; Daniel Schierbeck; [EMAIL PROTECTED]; Curt Zirzow Subject: Re: [PHP] Re: Crazy Serialize/Header/$_POST PHP Error - Is this a bug? 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" <[EMAIL PROTECTED]> To: "Daniel Schierbeck" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>; "Curt Zirzow" <[EMAIL PROTECTED]> 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:[EMAIL PROTECTED] Sent: Tuesday, August 24, 2004 4:53 AM To: [EMAIL PROTECTED] 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, > > Eric Try 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php