当我尝试将此文件包含在我的任何其他页面中时,它不起作用。有什么想法吗?文件结构:
index.php
(FOLDER - core) init.php
(FOLDER - functions) sanitise.php
(FOLDER - browse) blog.php , ecommerce.php...
(FOLDER - includes) header.php
我遇到的问题是当我尝试在我的任何文件中包含core / init.php时。您是否发现了我错过的任何错误或其他任何错误?
也许可以在我的includes / header.php文件中包含core / init.php,这样当我调用includes / header.php时,让我们说一下browse / blog.php,core / init.php也包含在内。我希望init.php能够包含在我的所有网页中。
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'
)
);
spl_autoload_register(function($class) {
require_once 'classes/' . $class . '.php';
});
require_once '/functions/sanitise.php';
?>
我的header.php文件代码:
<!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>
<!-- Menu Horizontal -->
<div class="horizontal">
<div class="webName">
<h3>WebA<font style="color: #c14a44;">ww</font>ards</h3>
</div>
<div id='cssmenu' class="twelve columns">
<ul>
<li class='active'><a href="/index.php"><span>Home</span></a></li>
<li class='has-sub'><a href='#'><span>Browse</span></a>
<ul>
<li class='has-sub'><a href='../browse/blog.php'><span>Blog</span></a></li>
<li class='has-sub'><a href='../browse/ecommerce.php'><span>E-Commerce</span></a></li>
<li class='has-sub'><a href='../browse/corporate.php'><span>Corporate</span></a></li>
<li class='has-sub'><a href='../browse/portfolio.php'><span>Portfolio</span></a></li>
<li class='has-sub'><a href='../browse/minimalist.php'><span>Minimalist</span></a></li>
<li class='has-sub'><a href='../browse/other.php'><span>Other</span></a></li>
</ul>
</li>
<li><a href='/login.php'><span>Register/ Login</span></a></li>
<li><a href='/submit.php'><span><font style="color: #68cd7a;">Submit Your Site</font></span></a></li>
</ul>
</div>
</div>
<div class="container">
浏览/ blog.php代码:
<?php
require_once('../core/init.php');
require ('../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>
文件无法执行,并且始终显示错误。
警告:require_once(../ core / init.php):无法打开流:第2行没有这样的文件或目录致命错误:require_once():打开所需的'../core/init失败。 php'(include_path =':')in - on line 2“
答案 0 :(得分:1)
你以错误的方式包括sanitise.php。
/functions/sanitise.php
将搜索根目录中的functions文件夹。
您应将其称为../functions/sanitise.php
。