Source for file serialize.examples.php
Documentation is available at serialize.examples.php
<script type="text/javascript" src="serialize.js"></script>
<script type="text/javascript">
var out = "Type: " + type + "\nContents: ";
out += (inp ? 'true' : 'false');
out += (ctype == "array" || ctype == "object" ? describe(inp[k]) : inp[k]) + "\n";
unserializer = new Unserializer;
'$foo = array("a" => 1, "b" => 2, 3);',
'$foo = array(1,2,array(1,2,3));',
'class Foo { var $foo; var $bar; }'
. '$foo = new Foo; $foo->foo = "hello"; $foo->bar = array("world","universe");'
echo '<h1><a name="pos">Positives</a> | <a href="#neg">Negatives</a></h1>';
for ($i = 0; $i < $c; $i++ ) {
echo " <strong>PHP Code:</strong>\n<pre>$examples[$i]</pre>\n<strong>PHP value:</strong><pre>\n";
echo "</pre>\n<strong>Serialized in PHP:</strong>\n<pre>", $sfoo, "</pre>\n",
"<strong>Unserialized in JS:</strong>\n<pre>\n",
'<script type="text/javascript">',
'var sfoo = unescape("', urlencode($sfoo), '"); var usfoo = unserializer.unserialize(sfoo); if (unserializer.error) {',
'document.write("Error: " + unserializer.getError() + "\n"); } document.write(describe(usfoo) + ',
'"</pre>\n<strong>Serialized in JS:</strong>\n<pre>" + serialize(usfoo));', "</script>\n</pre>\n<hr />\n\n";
'a:3:{s:1:"aa";i:1;s:1:"b";i:2;i:0;i:3;}',
'a:4:{s:1:"a";i:1;s:1:"b";i:2;i:0;i:3;',
'a:3:{i:1;s:1:"b";i:2;i:0;i:3;}',
'O:3:"Fooo":2:{s:3:"foo";s:5:"hello";s:3:"bar";a:2:{i:0;s:5:"world";i:1;s:8:"universe";}}',
'O:3:"Foo":3:{s:3:"foo";s:5:"hello";s:3:"bar";a:2:{i:0;s:5:"world";i:1;s:8:"universe";}}',
'O:3:"Foo":2:{s:5:"hello";s:3:"bar";a:2:{i:0;s:5:"world";i:1;s:8:"universe";}}',
'O:3:"Foo":2:{s:3:"foo";s:5:"hello";s:3:"bar";a:2:{i:0;s:5:"world";i:1;s:8:"universe";}',
'O:3:"Foo":2:{s:3:"foo";s:5:"hello";s:3:"bar";a:2:{i:0;s:5:"world";i:1;s:8:"universe"}}'
echo '<h1><a href="#pos">Positives</a> | <a name="neg">Negatives</a></h1>';
foreach ($bad_examples as $sfoo) {
echo "</pre>\n<strong>Invalidly serialized:</strong>\n<pre>", $sfoo, "</pre>\n",
"<strong>Unserialized in JS:</strong>\n<pre>\n",
'<script type="text/javascript">',
'var sfoo = unescape("', urlencode($sfoo), '"); var usfoo = unserializer.unserialize(sfoo); if (unserializer.error) {',
'document.write("Error: " + unserializer.getError() + "\n"); } document.write(describe(usfoo));',
"</script>\n</pre>\n<hr />\n\n";
Documentation generated on Mon, 11 Mar 2019 14:11:25 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|