Generating Javascript from PHP?
<p>Are there any libraries or tools specifically designed to help PHP programmers write Javascript? Essentially, converting the PHP logic into Javascript logic. For instance:</p>

<pre><code>$document = new Document($html);
$myFoo = $document-&gt;getElementById("foo");
$myFoo-&gt;value = "Hello World";
</code></pre>

<p>Being converted into the following output:</p>

<pre><code>var myFoo = document.getElementById("foo");
myFoo.value = "Hello World";
</code></pre>

<p>So the <code>$html</code> that is passed in won't initially be modified by the PHP. Instead, the PHP will convert itself into Javascript which is then appended onto the end of the <code>$html</code> variable to be ran when the variable it output and converted into the client-side DOM.</p>

<p>Of course it would be excellent if more complicated solutions could be derived too, perhaps converting objects and internal methods into javascript-objects, etc.</p>
