Unserialize PHP with JavascriptAbstractSimply, this is a Javascript library for decoding the output of the PHP serialize() function. It supports the following datatypes:
UsageThis is the source of the example.
<?php
ExampleAn example (as shown above) is here. CaveatsSince PHP5 supports protected and private class members and Javascript doesn't, these are converted into regular public members on the resulting Javascript object. Also, since the output of the PHP serialize() function can contain characters not normally allowed in a Javascript string literal, it must be escaped first. There's a function (as shown above) in the download that can do this. Unserialize in other languagesFor your perusing leisure, here's a list of unserialize() implementations in other languages courtesy of Yahoo!: TODONaturally, a PHP_Serialize() function would complement this library rather nicely, and not surprisingly, it's in the pipeline. Link to meIf you use any of the code on this site (and if you don't I guess) or it makes your life easier, I'd appreciate a link - http://www.phpguru.org. Thanks.
Author: Richard Heyes
Posted: 26th February 2006 23:22 Joshua Eichorn:
Quote> First I would say that using JSON for something > like this is a much better plan. Its going to > be supported by a C extenstion by default in at > least PHP6, and already has a C and PHP > implementation today. Tomato, tomatoe. The end result is the same. > That being said some HTML_AJAX dev's wanted to > do the same thing, so there is a PHP > unserialize and serialize implementation in > HTML_AJAX. Here again it's being suggested (see RPC article and comment about PEAR::XMLRPC2) to use code which has been given a version number lower than than the number of seconds it takes light from my lamp to reach my eyes. If this code works, and has been well tested, then it deserves a decent version number, otherwise it is suggestive that it's either alpha or beta quality, and thus shouldn't be used in production.
Author: Michael Phipps
Posted: 27th February 2006 07:57 Perhaps I'm just not thinking straight - but what can you do with this script? It's not clear why you would use this rather than unserializing the data in php first.
QuoteI'm probably missing something quite obvious.
Author: Richard Heyes
Posted: 27th February 2006 09:24 Michael Phipps:
Quote> Perhaps I'm just not thinking straight - but > what can you do with this script? It's not > clear why you would use this rather than > unserializing the data in php first. > > I'm probably missing something quite obvious. You can use it to pass data structures between PHP and Javascript. Eg, you have an array that you want to use in Javascript. You can serialize it in PHP, echo the string out in your page, unserialize it, and use it.
Author: andr3a
Posted: 11th May 2006 15:46 JavaScript PHP_Serializer , sounds good ? :-)
Quotehttp://www.devpro.it/javascript_id_102.html
Author: Saravanan
Posted: 26th May 2006 05:45 Could you help me that how to call the php function into the html tag?
Quote<? function abc() { echo "hello"; } echo '<html><body>'; echo '<input type=button name=b value=click onclick="abc()">'; echo '</body></html>'; ?> Thanks and regards, Saravanan
Author: Saravanan
Posted: 26th May 2006 05:51 Could you help me that how to call the php function into the html tag?
Quote<? function abc() { echo "hello"; } ?> <html><body> <input type=button name=b value=click onclick="<? abc() ?>"> </body></html>
Author: lckheng
\r\n> \r\n> \r\n> \r\n> value="click" onlick="funcClick(\'lckheng\');">\r\n> \r\n> Posted: 4th June 2006 06:53 <html>
Quote<head> <script language="javascript"> function funcClick(name){ <?php $phpName = name; //here problem.. ?> htxtname.value = <?php echo $phpName; ?>; } </script> </head> <body> <input type="text" id="htxt" name="htxt"> <input type="button" id="hbtn" name="hbtn" value="click" onlick="funcClick('lckheng');"> </body> </html> this is for example... i wanna assign the parameter to php's variable..if i use the javascript function... |

Comments
Posted: 26th February 2006 23:10
That being said some HTML_AJAX dev's wanted to do the same thing, so there is a PHP unserialize and serialize implementation in HTML_AJAX.
http://websvn.bluga.net/wsvn/HTML_AJAX/trunk/js/serializer/phpSerializer.js?op=file&rev=0&sc=0