USER_AGENT
ブラウザー (文字列を使用) とプラットフォーム (PHP-Mobile-Detect を使用)の両方をプログラムで検出する条件付きシステムをセットアップしようとしています。私の現在のセットアップは、おおよそ次のようになります。
<DOCTYPE html>
<html>
<head>
<?php
include("Mobile_Detect.php");
$detect = new Mobile_Detect();
?>
<?php if($detect->isiPad()) {
echo '<link rel="stylesheet" href="/style/iPad.css" type="text/css">';
}
else
{
echo '<meta charset="UTF-8">
<link rel="stylesheet" href="/style.css" type="text/css">;
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== false)
{
echo '<link rel="stylesheet" href="../style/splash-webkit.css" type="text/css">';
}
//and so on for other browsers
[etc]'
}
ここで発生する明らかな問題は、 間の競合'
です。echo
underは、私が望むようにタグelse
の最後で終わるのではなく、最初の宣言にあるように、コードに最初に現れる場所で終わります。この問題を回避するにはどうすればよいですか?<style>
'
USER_AGENT