I usually like to use as little code as possible by using short tags some will say that short tags should be avoided but i find it to my liking here is how I normally do it.
Code:
<script language='javacript'>var myVar=<?=$phpVar?></script>
__________________________________________________ ________
I am DJ Kat...that's my name. Its a D and a J and a Kat with a K.