Skip to content

Instantly share code, notes, and snippets.

@philsturgeon
Created November 24, 2009 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philsturgeon/241954 to your computer and use it in GitHub Desktop.
Save philsturgeon/241954 to your computer and use it in GitHub Desktop.
<?php
$array = array(
'Appt with my IFA: cxzcsdf Wed. 10:30',
'Transfer some cas\\zh to my SIPP ready to invest in R&M Global Opportunities on launch'."\n",
'Research and switch from my gilts fund to an emerging markets fund'
);
$serialized = serialize($array);
echo '<strong>Serialized</strong>: ' .$serialized .'<br/><br/>';
$urlencoded = urlencode($serialized);
echo '<strong>Encoded:</strong> <a href="?encoded=' .$urlencoded .'">' .$urlencoded .'</a><br/><br/>';
if( isset($_GET['encoded']) )
{
echo '<strong>Encoded from GET:</strong> ' . $_GET['encoded'] .'<br/><br/>';
$decoded = urldecode($_GET['encoded']);
echo '<strong>Decoded from GET:</strong> ' . $decoded .'<br/><br/>';
$decoded_array = unserialize($decoded);
echo '<strong>Decoded from GET:</strong> ' . print_r($decoded_array, TRUE) .'<br/><br/>';
}
echo "<h2>Final verdict!</h2>";
var_dump($array === $decoded_array);
echo "<h2>Whhhhhhhy?!</h2>";
var_export($array);
echo "<br/><br/>";
var_export($decoded_array);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment