<? $var = "Hello, world"; ?> <script> var a = "<? echo $var ?>"; </script>
<? $var = "Hello, world"; echo '<script language="javascript">var a = '.$var.';</script>'; ?>