从非移动设备检测启动页面PHP文件

从非移动设备检测启动页面PHP文件,php,Php,我试图调用一个php文件,该文件仅在有人从非android或iOS设备单击链接时打开。以前我只收到一条错误消息 if(isset($_GET['appId'])){ $products = getAppDownloadLinks(mysql_string($_GET['appId'])); //do something with this information if( $iPod || $iPhone || $iPad){ header('Location: '.$products[

我试图调用一个php文件,该文件仅在有人从非android或iOS设备单击链接时打开。以前我只收到一条错误消息

if(isset($_GET['appId'])){

$products = getAppDownloadLinks(mysql_string($_GET['appId']));
//do something with this information
if( $iPod || $iPhone || $iPad){
    header('Location: '.$products['ios']);
    exit;
}
else if($Android){
    header('Location: '.$products['android']);
    exit;
}
else{
    //we're not a mobile device.
    $html = file_get_contents('mobileSplash.php');
    }
}

对于我的最后一个else语句,这是合适的方法吗?我如何调用该php文件来显示splash错误页面

您可以通过以下方式将用户代理与一起使用

if(isset($_GET['appId']))
{

     $products = getAppDownloadLinks(mysql_string($_GET['appId']));
     $apple = (preg_match($ua, "/(iPhone|iPod|iPad)/") === 1);
     $android = (preg_match($ua, "/(Android)/") === 1);
     //do something with this information
     if($apple)
     {
         header('Location: '.$products['ios']);
         exit;
     }
     elseif($android)
     {
         header('Location: '.$products['android']);
         exit;
     } else
     {
         //we're not a mobile device.
         $html = file_get_contents('mobileSplash.php');
     }
 }

这正是我从你的问题文本中得到的。您可能需要将其实现到您的脚本文件中,或者按照您希望的方式对其进行编辑。

您应该检查此链接::)我个人会使用一个库,例如(如果算法是从零开始制作的),那么您建议如何调用php文件?@BhoffDev经过6分钟的工作后,您会更清楚一点。我希望如此。