使用JS或PHP检查用户处理器体系结构

时间:2013-05-11 17:41:45

标签: php javascript architecture bits

我想使用PHP或JavaScript检查useragent处理器架构,然后根据他们使用的架构将用户重定向到域。

E.G。

if($Bits32){ //redirect to somewhere
} elseif($Bits64){ //redirect to somewhere
}

我尝试使用以下代码但它无法正常工作:

if (navigator.userAgent.indexOf("WOW64") != -1 || 
    navigator.userAgent.indexOf("Win64") != -1 ){
   document.write("This is a 64 bit OS"); // 64 bit action 
} else {
    document.write("<br><br>");
   document.write("32 bit OS"); //32bit action
}

1 个答案:

答案 0 :(得分:0)

PHP无法在服务器端运行脚本时检测到它。您现在可以尝试使用userAgent,但是您必须记住并非每个人都使用默认的完整信息,因此总会有一些人无法使用的示例。

这可能会有所帮助,虽然它不会完全解决它。 http://blog.endflow.net/?p=285

tl; dr - 寻找更多的WOW64和Win64;)因为你可以看到不同的apss给出了不同的UserAgent,所以就像我告诉你的那样 - 不会对所有人都有效。