【发布时间】:2014-03-14 20:06:54
【问题描述】:
我知道以前有人问过这个问题,但是即使在阅读了其他帖子之后,我也无法弄清楚发生了什么......
请看看我的代码结构,看看我做错了什么..
文件夹结构:
index.php
(文件夹 - 包括)header.php
(文件夹 - 浏览)blog.php、ecommerce.php、other.php
(文件夹 - 核心)init.php
我正在尝试在浏览文件夹中包含 blog.php 中的包含文件夹中的 Header.php。下面是我的 header.php 代码。
头文件位于 Includes 文件夹中
<!DOCTYPE html>
<!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
<head>
<!-- Basic Page Needs
================================================== -->
<meta charset="utf-8">
<title>Web Awwards | Web Gallery | Submit your site</title>
<meta name="description" content="">
<meta name="author" content="">
<!-- Mobile Specific Metas
================================================== -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!-- CSS
================================================== -->
<link rel="stylesheet" type="text/css" href="../css/base.css">
<link rel="stylesheet" type="text/css" href="../css/skeleton.css">
<link rel="stylesheet" type="text/css" href="../css/layout.css">
<link rel="stylesheet" type="text/css" href="../css/styles.css">
<link rel="stylesheet" type="text/css" href="../css/menu.css">
<link rel="stylesheet" type="text/css" href="../css/submission.css">
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- Favicons
================================================== -->
<link rel="shortcut icon" href="images/favicon.ico">
<link rel="apple-touch-icon" href="images/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png">
</head>
<body>
<?php
require_once('core/init.php');
?>
<!-- Menu Horizontal -->
<div class="horizontal">
<div class="webName">
并浏览文件夹blog.php文件代码:
<?php
include './includes/header.php';
?>
<!-- TODO PHP Scripts -->
<div class="category nine columns">
<div class="category-img">
<img src="css/img/webImg/screen1.png" alt="Site Description"/>
</div>
<h3> Web Name </h3>
<h5> Designed By: Tautvydas Slegaitis </h5>
<h7> Designers url </h7>
<div class="vote">
<h4> Vote for my site </h4>
</br>
<a href="#"> Love it </a>
<a href="#"> Nope, Not for me </a>
</div>
</div>
</div><!-- Close Container Div -->
<div class="footer">
</div>
</body>
</html>
但它不起作用。我不知道为什么,...请帮我解决这在过去 2 天里杀死我的问题。 Coda 2 显示错误
" 警告:include(./includes/header.php):无法打开流:第 2 行中没有此类文件或目录 警告:include():打开 './includes/header.php' 失败包含 (include_path='.:') 在 - 第 2 行“
init.php 代码:
<?php
session_start();
$GLOBALS['config'] = array(
'mysql' => array(
'host' => 'localhost',
'username' => 'root',
'password' => 'root',
'db' => 'webAwwards'
),
'remember' => array(
'cookie_name' => 'hash',
'cookie_expire' => 604800
),
'session' => array(
'session_name' => 'user'
)
);
// TODO Remove parenthesis in require once if doesnt work
spl_autoload_register(function($class) {
require_once('classes/' . $class . '.php');
});
require_once('/functions/sanitise.php');
?>
【问题讨论】:
-
./应该是../。 -
如果我添加 ../ 它包含标题但随后停止执行 blog.php 的其余部分,如果我在浏览器中查看源代码仅显示 header.php 代码
-
尝试使用
require而不是include。 -
如果我使用 require 它不会改变任何东西。我真的没有想法不知道发生了什么
标签: php include-path