<?php $i = 0; ?> <script type="text/javascript"> *!* var i = <?php echo $i ?> */!* alert(i); //0 </script>