php在javascript中? [英] php in javascript?

查看:85
本文介绍了php在javascript中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在javascript中有一些PHP代码

i need to have some php code inside javascript

      <script ...>

        <?php
        echo " ... ";
        ?>

       </script>

但这不起作用。你怎么能在自己的文件javascript.php中的javascript中实现php?

but this doesnt work. how can u implement php inside javascript that is in a own file javascript.php?

推荐答案

那不能做你想做的事情认为它确实如此。它可以工作,但PHP在页面加载时运行一次,而不是每次调用JavaScript函数时都运行。

That doesn't do what you probably think it does. It'll work, but the PHP gets run once, when the page is loaded, not every time the JavaScript function is called.

这篇关于php在javascript中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆