73
rated 0 times
[
75]
[
2]
/ answers: 1 / hits: 54869
/ 12 Years ago, mon, august 13, 2012, 12:00:00
I need to write some PHP code inside a Javascript's document.write()
. This is a dummy example, but in the future Javascript will generate automatically that PHP code.
This is the Hello World I have coded:
MyFile.php
<html>
<body>
<script type=text/javascript>
document.write(<?php echo Hello World; ?>);
</script>
</body>
</html>
However, nothing is displayed, and in the DOM file I get this:
<html>
<body>
<script type=text/javascript>
<!--?php echo Hello World; ?-->
</script>
</body>
</html>
Any help? Thanks
More From » php