<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="http://www.bytemycode.com/rssformat.xsl"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title>byteMyCode: Snippets for "object passing"</title>
		<link>http://www.bytemycode.com</link>
		<description>Snippets for this tag.</description>
		<pubDate>Tue, 02 Dec 2008 16:03:26 +0000</pubDate>
		<copyright>1998-2008 </copyright>
		<language>en-us</language>
		<image>
		      <link>http://www.bytemycode.com</link>
		      <url>http://www.bytemycode.com/img/rss_title.gif</url>
		      <title>byteMyCode</title>
		</image>

	<item>
	<title>Javascript->PHP serializer</title>
	<link>http://www.bytemycode.com/snippets/snippet/666/</link>
	<comments>http://www.bytemycode.com/snippets/snippet/666/comments/</comments>
	<pubDate>Mon, 04 Jun 2007 15:06:47 +0000</pubDate>
	<dc:creator>Fordiman</dc:creator>
	<category>"object passing", JavaScript, PHP, serialize</category>
	<guid isPermaLink="false">http://www.bytemycode.com/snippets/snippet/666/</guid>
	<description>
		<![CDATA[

			<img src="http://www.bytemycode.com/img/icon_calendar.gif" align="middle" class="icon" alt="Date Submitted" /> Mon. Jun. 4th, 2007  3:06 PM			<br />
			<img src="http://www.bytemycode.com/img/icon_revision.gif" align="middle" class="icon" alt="Revision" /> <a href="http://www.bytemycode.com/snippets/snippet/666/revisions/">1</a>
			<br />
			<img src="http://www.bytemycode.com/img/rank_scripter.gif" align="middle" class="icon" alt="Scripter" /> <a href="http://www.bytemycode.com/members/member/Fordiman/" title="Scripter">Fordiman</a>
			<br />
			<img src="http://www.bytemycode.com/img/icon_tag.gif" align="middle" class="icon" alt="Tags" /> <a href="http://www.bytemycode.com/tags/tag/%22object+passing%22">"object passing"</a>&nbsp;|&nbsp;<a href="http://www.bytemycode.com/tags/tag/JavaScript">JavaScript</a>&nbsp;|&nbsp;<a href="http://www.bytemycode.com/tags/tag/PHP">PHP</a>&nbsp;|&nbsp;<a href="http://www.bytemycode.com/tags/tag/serialize">serialize</a>			<br />
			<img src="http://www.bytemycode.com/img/icon_comments.gif" align="middle" class="icon" alt="Comments" /> <a href="http://www.bytemycode.com/snippets/snippet/666/comments/">6 comments</a>
			<br />
			<img src="http://www.bytemycode.com/img/icon_ranking.gif" align="middle" class="icon" alt="Ranking" /> 6
			<p>This is a quick set of overrides for Javascript so that any variable can be passed to PHP in a GET/POST activity.  Just call myVar.toPHP();<br /><br />I use this little set of functions extensively in a little Javascript/PHP RPC handler I wrote.  I don't have the reverse function, as I pass JSON back to the browser for the return value.<br /><br />Note: This lib is not safe for binaries or HTML Elements.  The former will come out similar to FTP ASCII breaks, and the latter will cause infinite recursion.  If you want to make a speical case for HTML Elements, do so; you could probably just test for parentNode and create a 'safe' object from that.  I didn't need it, so I didn't code it.<br /><br />As for binary safety, at some point between toPHP/escape/post/urldecode/unserialize, the object breaks.  Rather than create a huge fix for something I didn't need to do, I put in a quick match/hack.  Don't like it?  Write the fix yourself.</p>
		]]>
	</description>
</item>
	</channel>
</rss>