【发布时间】:2019-02-11 18:13:36
【问题描述】:
我修改了 detectmobilebrowsers.com php 脚本,在重定向中传递的 url 中写入 1 或 0,这样我就可以根据查看浏览器是否为移动设备编写我需要的样式表。如果是移动浏览器,添加?det=0 或?det=1 非常有用。但是,在我的头文件中,无论 url 中 det 的值如何,我的 IF 语句总是返回非移动 html。我确定这是初级的,但我无法理解!
我使用的网址格式是 www.cypressbotanicals.com/main.php?det=1
摘自header.php的
部分:<?php
$mob = $_GET['$det'];
if($mob==1): ?>
<link rel="stylesheet" href="css/mobile.css" type="text/css" media="screen" /><!--is mobile-->
<?php else: ?>
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" />
<?php endif ?>
<link rel="stylesheet" href="css/scheck.css" type="text/css" media="screen" />
【问题讨论】:
-
试试
$_GET['det'];(从数组键名中去掉$) -
当然,就是这样!谢谢!
标签: php html variables url get