Methods of passing JavaScript variables into a PHP script

zhaozj2021-02-16  48

Author: little Xinyuan http://www.w8c.com

Method 1: First use PHP to generate JS code, then pass the JavaScript variable to the PHP script through the automatic refresh of the browser.

var QQ = 'My QQ is 6616457
'; location.href = '? & qq =' qq; "; EXIT ();} // Note: In practical applications, it is necessary to prevent the user from changing the variable value delivered in the address bar.

$ Web = "I am a little bit!". $ qq; echo $ web;?>

Method 2: First write the JS variable into the cookie with the Document.cookie method, and then remove it with PHP.