该脚本的输出可能是:mozilla/4.0 (compatible; msie 6.0; windows nt 5.1; sv1)
php 有很多种不同类型的变量,在以上例子中我们打印了一个数组的元素,数组是一类非常有用的变量.
$_server 只是 php 自动全局化的变量之一,您可以查阅“保留变量”一节来查看这些变量的列表,或者也可以建立如下的文件来得到一个完整的列表.
php 根据http_user_agent 判断用户浏览器类型,代码如下:
function browsers() { global $http_user_agent; if (isset($http_user_agent)) { $sagent = $http_user_agent; } else { $sagent = $_server['http_user_agent']; } if (strpos($sagent, 'msie') !== false && strpos($sagent, 'mac') === false && strpos($sagent, 'opera') === false) { $iversion = (float)substr($sagent, strpos($sagent, 'msie') + 5, 3); return ($iversion >= 5.5); } else if (strpos($sagent, 'gecko/') !== false) { $iversion = (int)substr($sagent, strpos($sagent, 'gecko/') + 6, 8); return ($iversion >= 20030210); } else { return false; }}
可以得到链接/提交当前页的父页面url,代码如下:
click me!
教程网址:
欢迎收藏∩_∩但请保留本文链接。