<html> <body> <?php $myScript = "Hey World!"; ?> <script type="text/javascript"> document.write("<?php echo $myScript ?>"); </script> <?php //....php code... ?> </body> </html>