1<script>
2var p1 = "success";
3</script>
4
5<?php
6echo "<script>document.writeln(p1);</script>";
7?>
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
1<?php
2 $color = "Red";
3?>
4<script type="text/javascript">var color = "<?= $color ?>";</script>
5<script type="text/javascript" src="file.js"></script>
6