How to output JavaScript with PHP

Posted by krishna on Stack Overflow See other posts from Stack Overflow or by krishna
Published on 2009-07-22T09:36:52Z Indexed on 2010/04/13 22:13 UTC
Read the original article Hit count: 255

Filed under:

Hi, I am new to PHP. I need to output the following JavaScript with PHP. This is my code:

<html>
<body>
<?php

echo "<script type="text/javascript">";
echo "document.write("Hello World!")";
echo "</script>";

?>
</body>
</html>

But it's showing the error:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /var/www/html/workbench/person/script.php on line 4

Can anyone please help? I also need some simple tutorials on how to use PHP, HTML and JavaScript for an application.

© Stack Overflow or respective owner

Related posts about php