Php 如何在Windows中使用目录分隔符

Php 如何在Windows中使用目录分隔符,php,Php,我正试图弄明白为什么我会犯这个错误 **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 t

我正试图弄明白为什么我会犯这个错误

**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');

?>

我不认为这是一个目录分隔符问题:您可以在Windows上同时使用正向斜杠和反向斜杠

问题在于:

\C\wamp\www\PHP with MySQL Beyond the Basics
除非当前驱动器的根路径中有一个名为
C
的目录,否则您真正想要的是

C:\wamp\www\PHP with MySQL Beyond the Basics

我想这就是mw的工作原理

defined('SITE_ROOT') ? null : 
define('SITE_ROOT', 'C:'.DS.'wamp'.DS.'www'.DS.'photo_gallery');