我正在尝试使用ob
函数显示索引文件。我非常接近它,唯一的问题不是一切都是正确的。当文件加载时,只使用了一些css文件。它们似乎都被正确包含但只有一个被应用而不是全部。我正在使用的功能集有什么问题吗?也许我需要使用不同的?
这是获取内容的方法。
public function get($file)
{
if(file_exists($file))
{
ob_start();
include $file;
$out1 = ob_get_contents();
return $out1;
}
else
{
return "File not found.";
}
}
$file
可以是任何html文件,如下所示:
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link rel="stylesheet" href="css/foundation.css" type="text/css"/>
<link rel="stylesheet" href="css/screen.css" type="text/css"/>
<link href='http://fonts.googleapis.com/css?family=Lekton:400,700,400italic' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300' rel='stylesheet' type='text/css'>
<script src="js/vendor/modernizr.js"></script>
</head>
<body>
<div id="container_border">
<div id="contact_info">
<ul>
<li>Email: <a href="mailto:test@google.com">test@google.com</a></li>
<li>Phone: <a href="tel:123345355">123345355</a></li>
<li>Quality products & hassle-free service.</li>
</ul>
</div>
<div class="row" id="header_bg">
<img src="img/logo.png" alt="Physician Associates Logo" id="logo">
</div>
<div class="row" style="background-color: #f5f5f5;">
<div class="medium-6 columns main_padding" id="container_content">
<h1>Who We Are</h1>
<p>
We like to keep things simple. Contact us today using our form to request more information, or call us directly. We appreciate your business!
</p>
</div>
<div class="medium-6 columns main_padding" id="container_form">
<form action="contact.php" method="post">
<div class="row">
<div class="medium-6 columns">
<label for="name">Name</label><input class="input_custom" name="name" type="text">
</div>
<div class="medium-6 columns">
<label for="name">Practice</label><input class="input_custom" name="practice" type="text">
</div>
</div>
<div class="medium-12">
<label for="email">E-mail</label><input class="input_custom" name="email" size="50" type="text">
</div>
<div class="medium-12">
<label for="subject">Subject</label><input class="input_custom" name="subject" size="50" type="text">
</div>
<label for="message">Message</label>
<textarea name="message"></textarea>
<input class="button small radius" value="Send" type="submit">
</form>
</div>
</div>
</div>
<script src="js/vendor/jquery.js"></script>
<script src="js/foundation.min.js"></script>
<script>
$(document).foundation();
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-47882868-1', 'physicianassociates.com');
ga('send', 'pageview');
</script>
</body>
</html>
当get()
方法返回内容时,它简单地回显了所有内容。当我检查页面上的元素时,html源看起来与上面的代码完全一样。所有的图像都很好,但不是所有的CSS都只显示某些文件。包含文件,我没有错误说无法找到它们。
答案 0 :(得分:0)