How to get js variables in php
When using php to build a website, we often need to interact with the front-end page Interaction, sometimes we also need to get the value in the js variable through php. In this case, we can get the variable by embedding the js code in it.
1. First, we create a test php file.
2. Add the code required for html inside.
3. We add a js script inside and define a variable 100.
4. Now we add the php code at the bottom, in which we define a b variable with a default value of 0, ready to use it To receive the value of a in js.
5. Then we use writeln in the script to output a and assign it to the variable b in php. At the end The echo output checks the value in b.
6. Opening this php file in the browser will directly echo the value of variable a in js as 100. At this point, php has completed obtaining the variables in js.
For more PHP related knowledge, please visit PHP Chinese website!
The above is the detailed content of How to get js variables in php. For more information, please follow other related articles on the PHP Chinese website!