Execute javascript in PHP
- by Andreas Bonini
I'm generating your typical Web 2.0 HTML page with PHP: it contains a lot of <script> tags and javascript code that will substantially change the DOM after the load event.
Is there a way to get the final HTML code directly from PHP, without opening the page with any browser?
For example, let's say the HTML for the page is (it's just an example):
<html>
<head>
<script>...the jquery library code...</script>
<script>$(document).ready(function() { $("body").append("<p>Hi!</p>");</script>
</head>
<body>
</body>
</html>
This HTML is saved in the $html PHP variable. Now, I want to pass that variable to some function that will return $result = <html>....<body><p>Hi!</p></body></html>.
Is this possible?