我有一个响应式Wordpress站点: www.2eenheid.de。我的客户想要在手机上有一个全尺寸查看网站的选项,这是一个选择退出的响应式选项。现在,在一个程序员的帮助下,我得到了这个:
<?php ini_set('display_errors', true);
session_start();
if(isset($_REQUEST['resp'])) {
$_SESSION['resp'] = (bool)($_REQUEST['resp']);
}
// Check if enabled
$enabled = isset($_SESSION['resp']) && $_SESSION['resp'];
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<?php if($enabled): ?>
<meta name="viewport" content="width=device-width">
<?php endif; ?>
<title>LALALA</title>
</head>
<body <?php body_class(); ?> id="<?php if(isset($_SESSION['resp']) && $_SESSION['resp']) { echo "resp"; } ?>">它在某种程度上有效。每当我调用链接www.2eenheid.de/?resp=1时,我的网站就会在移动设备上变成响应式,但当我点击其他页面时,它不会保存这个设置,我需要这样做。另外,有些页面是响应式的,有些则不是,我觉得我在$_SESSION['resp'] = (bool)($_REQUEST['resp']);上做错了什么。有人有什么想法吗?
发布于 2013-07-19 19:50:12
尝尝这个
if(isset($_SESSION['resp'])){
$enabled = true;
}else{
$enabled = false;
}使用这个来代替
$enabled = isset($_SESSION['resp']) && $_SESSION['resp'];https://stackoverflow.com/questions/17745306
复制相似问题