简体   繁体   English

如何从Java脚本获取值然后存储在php变量中

[英]how to get value from java script then store in php variable

Duplicate: 重复:
Access a JavaScript variable from PHP 从PHP访问JavaScript变量

hi 你好

i want get value from java script, then i will use the value in php, both are in single php file. 我想从Java脚本中获取价值,那么我将使用php中的值,两者都在单个php文件中。

send how to connect with these two in single file.... 在单个文件中发送如何与这两个连接。

thanks 谢谢

you can use post or get request to your current page (or to another page) using <form> tag or ajax. 您可以使用<form>标记或ajax对当前页面(或另一个页面)使用发布或获取请求。 Then in the php you will use $_REQUEST (or $_POST or $_GET ) which act as associative array with the key being the name of your variable. 然后在php中,您将使用$ _REQUEST (或$ _POST$ _GET )作为关联数组,其键为变量名。 So if you submitted mypage.php?foo=bar 因此,如果您提交了mypage.php?foo = bar

in php $_REQUEST['foo'] will be bar. 在PHP $_REQUEST['foo']中将是吧。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM