2014-02-15 70 views
2

當我嘗試將此文件包含在我的任何其他頁面中時,它不起作用。任何想法爲什麼?文件結構:包含此文件不起作用

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> 

文件不執行並且始終顯示錯誤。

Warning: require_once(../core/init.php): failed to open stream: No such file or directory in - on line 2 Fatal error: require_once(): Failed opening required '../core/init.php' (include_path='.:') in - on line 2 "

+1

在你的init.php中調用sanitise.php爲'../ functions/sanitise.php' – 2014-02-15 16:21:51

+1

回答這個問題我會接受它。 Worked .. :) thx – Tauciokas

+0

現在輪到你了:) – 2014-02-15 16:34:37

回答

1

您以錯誤的方式包含sanitise.php。

/functions/sanitise.php將在根目錄下搜索功能文件夾。

你應該把它叫做../functions/sanitise.php

相關問題