由于使用javascript (通常情况下)客户端的技术,和PHP (通常情况下)服务器端技术,自从HTTP是一种“无国籍”协议,两种语言不能直接共享变量。
然而,人们可能通过变量两者之间的关系。途径之一是完成这一创造javascript代码用PHP ,并刷新浏览器本身,通过特定变量返回的PHP脚本。下面的例子恰恰说明如何做到这一点-它使P HP代码捕获屏幕的高度和宽度,这通常是唯一可能在客户端。htmlspecialchars()函数
echo "n";?>
php url
echo "n";?> if (isset($_GET['width']) AND isset($_GET['height'])) { // output the geometry variables echo "Screen width is: ". $_GET['width'] ."n"; echo "Screen height is: ". $_GET['height'] ."n";} else { // pass the geometry variables // (preserve the original query string // -- post variables will need to handled differently)
echo "n"; exit();}?>
公司环境 | 合作伙伴 | 人才招聘 | 付款方式 | 关于我们