javascript 如何将javascript变量放入php echo中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10853630/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 11:15:55 来源:igfitidea点击:
how to put javascript variable in php echo
提问by Osama Ahmad
I want to add JavaScript variable to php echo
我想将 JavaScript 变量添加到 php echo
arr[i]='<?php echo $winner[javascript variable]; ?>';
Thanks
谢谢
回答by Quentin
You can't.
你不能。
- PHP runs on the server and outputs some text.
- The text is sent to the browser
- The browser interprets the text as HTML / JavaScript / etc
- PHP 在服务器上运行并输出一些文本。
- 文本发送到浏览器
- 浏览器将文本解释为 HTML / JavaScript / 等
The PHP has finished running by the time the JavaScript is executed.
到执行 JavaScript 时,PHP 已完成运行。
If you want to pass data back you need to make a newHTTP request and run a PHP script from scratch.
如果您想将数据传回,您需要发出一个新的HTTP 请求并从头开始运行 PHP 脚本。