douzhao5656 2015-07-08 20:36
浏览 39
已采纳

如何在codeigniter中的javascript警报中使用php代码

I am using this code in my controller and it's not working, showing parse error. Can you guys please help me out.

 echo "<script>
        alert("<?php echo $v[$keys[$i+4]],"is going out of stock"; ?>");
</script>" ;

Thank you!

  • 写回答

1条回答 默认 最新

  • dousuohe5882 2015-07-08 20:46
    关注

    You're not concatenating the static text correctly. Try this:

    echo "<script>
        alert('" . $v[$keys[$i+4]] . " is going out of stock.');
    </script>" ;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?