“HTTP_USER_AGENT”无效。我的浏览器中没有显示任何内容,即firefox

时间:2010-07-19 17:32:12

标签: php environment-variables

<?php
$agent=getenv("HTTP_USER_AGENT");
if(preg_match("/MSIE/i", "$agent")){
    $result="You are using Microsoft Internet Explorer.";}
    else if (preg_match("/Mozilla/i", "$agent")){
    $result= "You are using Firefox.";}
    else {$result = " you are using $agent.";}

?>
<html>
<head>
<title>Browse Match Results</title>
</head>
<body>
<?php "<p>$result</p>";?>
</body>
</html>

2 个答案:

答案 0 :(得分:2)

我可能冒昧地猜测,并建议:

<?php "<p>$result</p>";?>

应该是:

<?php echo "<p>$result</p>";?>

答案 1 :(得分:0)

<?php 回声 "<p>$result</p>";?>