我想弄清楚为什么我会收到此错误。
**Warning: require_once(\C\wamp\www\PHP with MySQL Beyond the Basics\Chapter06\06_12_photo_gallery\includes\config.php) [function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\PHP with MySQL Beyond the Basics\Chapter06\06_12_photo_gallery\includes\initialize.php on line 16
Fatal error: require_once() [function.require]: Failed opening required '\C\wamp\www\PHP with MySQL Beyond the Basics\Chapter06\06_12_photo_gallery\includes\config.php' (include_path='.;C:\php5\pear') in C:\wamp\www\PHP with MySQL Beyond the Basics\Chapter06\06_12_photo_gallery\includes\initialize.php on line 16**
现在这里是index.php页面中的代码
<?php
require_once('../../includes/initialize.php');
if (!$session->is_logged_in()) { redirect_to("login.php"); }
?>
<?php include_layout_template('admin_header.php'); ?>
<h2>Menu</h2>
</div>
<?php include_layout_template('admin_footer.php'); ?>
以下是initialize.php页面的代码:
<?php
// Define the core paths
// Define them as absolute paths to make sure that require_once works as expected
// DIRECTORY_SEPARATOR is a PHP pre-defined constant
// (\ for Windows, / for Unix)
defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR);
defined('SITE_ROOT') ? null :
define('SITE_ROOT', DS.'C'.DS.'wamp'.DS.'www'.DS.'PHP with MySQL Beyond the Basics'.DS.'Chapter06'.DS.'06_12_photo_gallery');
defined('LIB_PATH') ? null : define('LIB_PATH', SITE_ROOT.DS.'includes');
// load config file first
require_once(LIB_PATH.DS.'config.php');
// load basic functions next so that everything after can use them
require_once(LIB_PATH.DS.'functions.php');
// load core objects
require_once(LIB_PATH.DS.'session.php');
require_once(LIB_PATH.DS.'database.php');
// load database-related classes
require_once(LIB_PATH.DS.'user.php');
?>
答案 0 :(得分:3)
我不认为这是目录分隔符问题:您可以在Windows上使用向前和向后斜杠。
问题在于:
\C\wamp\www\PHP with MySQL Beyond the Basics
除非您在当前驱动器的根路径中有一个名为C
的目录,否则您真正想要的是
C:\wamp\www\PHP with MySQL Beyond the Basics
答案 1 :(得分:0)
我认为这是如何为mw
工作的defined('SITE_ROOT') ? null :
define('SITE_ROOT', 'C:'.DS.'wamp'.DS.'www'.DS.'photo_gallery');