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 もインクルードされる可能性があります。すべての Web ページに 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): ストリームを開けませんでした: No such file or directory in - 行 2 致命的なエラー: require_once(): 必要な '../core/init.php' を開けませんでした ( include_path='.:') in - 行 2 で "

4

1 に答える 1

1

sanitise.php を間違った方法でインクルードしています。

/functions/sanitise.phpルート ディレクトリで functions フォルダーを検索します。

として呼び出す必要があります../functions/sanitise.php

于 2014-02-15T16:25:34.750 に答える