You can print the PHP variable into your javascript while your page is created.(您可以在创建页面时将PHP变量打印到javascript中。)
<script type="text/javascript">
var MyJSStringVar = "<?php Print($MyPHPStringVar); ?>";
var MyJSNumVar = <?php Print($MyPHPNumVar); ?>;
</script>
Of course this is for simple variables and not objects.(当然这是针对简单变量而不是对象。) 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…