如果有人能想到更好的标题,请告诉我。
现在,我正在使用this tutorial中的技术来获取用户查看窗口的宽度和高度。它有效,但仅在index.php页上。我正在使用php based css file.
在基于php的css文件中,所有内容通常都可以正常工作,只是顶部的第一行* $ width_div_center = $ GET ['width'] 0.8;认为宽度是字符串形式。 (或类似的东西。)因此,$ width_div_center变量设置为零,这会引起很多问题。我在做什么错,或者如何才能使基于php的css文件正确地对* $ GET ['width'] 0.8进行乘法运算?谢谢您的帮助。
<html>
<head>
<title>Taylor Love</title>
<!--
<link rel="stylesheet" media="only screen and (color)" href="main.css" />
<link rel="stylesheet" href="main.css"/>
-->
<link rel="stylesheet" type="text/css" href="css/style.php" />
<?php
$content = "null";
include_once('content.php');
?>
</head>
<body class="body">
<!-- top header -->
<div class="div-center decorated-white">
<div class="header-background">
<div style="margin:10px;">
<font color="#AAA" >
hello, universe!
<?php
echo $_GET['width'] *.8;
echo "<h1>Screen Resolution:</h1>";
echo "Width : ".$_GET['width']."<br>";
echo "Height : ".$_GET['height']."<br>";
?>
</font>
</div>
</div>
</div><!-- div-center-->
<div class="div-center" style="margin-top:10px;">
<?php
include('sidenav.php');
?>
<div id="div-content" class = "decorated-white">
<?php echo $content; ?>
</div><!-- div-content-->
</div><!-- div-center-->
<div class="clear"></div>
<!-- top header
<div class="div-center decorated-white" style="margin-top:10px">
<?php
for ($i = 0; $i < 5; $i++){
echo "</br>";
}
?>
</div>-->
</body>
</html>
///////////////////////////////////////////////////// //////////////////////////////
///////////////////////////////////////////////////// //////////////////////////////
我似乎在分离两个不同页面的代码时遇到问题。
最佳答案
您似乎在没有任何style.php
参数的情况下调用$_GET
。
在$_GET
中使用的index.php
参数不会自动传递给style.php
。脚本。
尝试对'width'参数进行临时硬编码,看是否有任何区别
<link rel="stylesheet" type="text/css" href="css/style.php?width=100" />
这是因为对样式表的请求是一个单独的GET请求,它不了解引用者的get参数。