2010-07-19 37 views
0
<?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> 
+0

微米。 ..你的PHP看起來像什麼?這不會起作用。 – Timothy 2010-07-19 17:33:47

+0

嘗試$ _SERVER [「HTTP_USER_AGENT」]並且您的瀏覽器正在發送用戶代理字符串? – Timothy 2010-07-19 17:35:49

+0

我正在使用Dreamweaver和從PHP6快速簡單的Web開發中學習。我輸入了它給出的代碼,它似乎沒有工作。 – Rookie9 2010-07-19 17:36:37

回答

2

我可以大膽猜測,並建議:

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

應該是:

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

哦,是的,我錯過了:) – 2010-07-19 17:38:52

+0

嘿Wrikken你真棒...我想知道你有多少時間進入PHP。 我從書中誤讀:P – Rookie9 2010-07-19 17:42:58

0

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

相關問題