Creating Javascript from PHP?

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.

+3
source share
2

, - http://xajaxproject.org. , ajax-. javascript. 2 , . , .

+5

?

, PHP , , JS-, () .

, , http://phpjs.org/

php.js - , PHP JavaScript, -...

+2

Source: https://habr.com/ru/post/1737880/


All Articles