Comment puis-je utiliser le DIRECTORY_SEPARATOR pour Windows
J'essaie de comprendre pourquoi j'obtiens cette erreur.
**Warning: require_once(\C\wamp\www\PHP with MySQL Beyond the Basics\Chapter06**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**
6_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**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**
6_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_12_photo_gallery\includes\config.php' (include_path='.;C:\php5\pear') in C:\wamp\www\PHP with MySQL Beyond the Basics\Chapter06**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**
6_12_photo_gallery\includes\initialize.php on line 16**
Voici maintenant le code de la index.php page
<?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'); ?>
Voici le code pour l'initialize.php page:
<?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');
?>
OriginalL'auteur Amen Ra | 2010-07-01
Vous devez vous connecter pour publier un commentaire.
Je ne pense pas que c'est un séparateur de répertoire de problème: Vous pouvez utiliser à la fois avant et en arrière des barres obliques sur Windows.
Le problème est ici:
sauf si vous avez un répertoire nommé
C
dans le chemin de la racine sur le disque en cours, ce que vous voulez vraiment estOriginalL'auteur Pekka 웃
Je pense qu'ici est de savoir comment il fonctionne pour mw
OriginalL'auteur Samuel.F