Are there libraries or tools specifically designed to help PHP programmers write Javascript? Essentially, converting PHP logic to JavaScript logic. For instance:
$document = new Document($html);
$myFoo = $document->getElementById("foo");
$myFoo->value = "Hello World";
Convert to the following output:
var myFoo = document.getElementById("foo");
myFoo.value = "Hello World";
Thus, the passed $htmlwill not be modified initially by PHP. Instead, PHP converts itself to Javascript, which is then added to the end of the variable $html, which runs when the variable that it outputs and converts to the client-side DOM.
Of course, it would be great if you could get more complex solutions, perhaps converting objects and internal methods to javascript objects, etc.
source
share