DIRECTORY_SEPARATOR on windows correct path

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
iamalex
Forum Newbie
Posts: 5
Joined: Thu Aug 12, 2010 10:11 am

DIRECTORY_SEPARATOR on windows correct path

Post by iamalex »

Can someone please help with writing the path correctly using the DS so I can upload and write to file folder to the right place. I can't seem to get it to work. Thank you in advance ... Alex
I am using localhost on windows machine.

The path on my machine is:

// C:\wamp/www/photo_gallery/public/images
// C:\wamp/www/photo_gallery/includes/config.php and other files

Code: Select all

<?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);

// need help here
defined('SITE_ROOT') ? null :
  define('SITE_ROOT', .DS.'wamp'.DS.'www'.DS.'photo_gallery');

// need help here  
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");
?>
User avatar
MindOverBody
Forum Commoner
Posts: 96
Joined: Fri Aug 06, 2010 9:01 pm
Location: Osijek, Croatia

Re: DIRECTORY_SEPARATOR on windows correct path

Post by MindOverBody »

Replace this:

Code: Select all

defined('DS') ? null : define('DS'), DIRECTORY_SEPARATOR);
with:

Code: Select all

defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR);
Closing bracket is what causing you headaches. ;)
Post Reply