我需要在JavaScript中回显PHP变量

时间:2016-12-31 11:24:24

标签: php

我的代码是

$selectedWallet = $_POST['wallet'];
  <script>
            $(document).ready(function(){
                     var oMain = new CMain({
                                    win_occurrence: 40,
                                    min_bet: 1,
                                    max_bet: 300,
                                    bet_time: 10000,
                                    money: "<?php echo $SelectedWallet; ?>",                 //STARING CREDIT FOR THE USER
                                    blackjack_payout: 1.5,
                                    game_cash: 500,
                                    fullscreen:true,
                                    check_orientation:true,
                                });
</script>

我需要在这个脚本中回显PHP变量,即money:&#34;

1 个答案:

答案 0 :(得分:1)

使用此选项,您将在一个变量中获取值并回显未定义的变量。

$selectedWallet = $_POST['wallet'];
 <script>
        $(document).ready(function(){
                 var oMain = new CMain({
                                win_occurrence: 40,
                                min_bet: 1,
                                max_bet: 300,
                                bet_time: 10000,
                                money: '<?php echo $selectedWallet; ?>',                 //STARING CREDIT FOR THE USER
                                blackjack_payout: 1.5,
                                game_cash: 500,
                                fullscreen:true,
                                check_orientation:true,
                            });
 </script>