1//passing PHP variable to JavaScript
2var myJSVar = <?php echo json_encode($myPHPVar); ?>;
1<script type="text/javascript">
2// boolean outputs "" if false, "1" if true
3var bool = "<?php echo $bool ?>";
4
5// numeric value, both with and without quotes
6var num = <?php echo $num ?>; // 7
7var str_num = "<?php echo $num ?>"; // "7" (a string)
8
9var str = "<?php echo $str ?>"; // "A string here"
10</script>
11