php how to obtain the value of the variable js

Use php to do the site, it often requires the front page we interact with, sometimes we need to get the value of a variable by js php, this case in the manner in which we can embed js code to get this variable.

First we create a test php file. (Recommended Learning: PHP Programming from entry to the master)

php-49.pngAdd code html needed inside.

php-50.pngWe add js script inside, a definition of a variable 100.

php-51.png

Now we add the bottom php code, which defines a default variable b is 0, ready to use it to receive a value of the js.

php-52.png

Then we use the script inside writeln outputs a, and assigned to php variables in b, b to see the value in the last echo output.

php-53.png

Open this file directly php echo a js variable has a value of 100, this js variables in php get done in the browser.

php-54.png

These are the details of how php get variable values ​​of js, php more please pay attention to Chinese networks other related articles!

Guess you like

Origin www.cnblogs.com/furuihua/p/11481917.html