How to output JavaScript with PHP

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.

How to output JavaScript with PHP