CodeIgniter Forums

Full Version: Defined constants - FCPATH
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

I got a problem with defined constant. FCPATH...
// Path to the front controller (this file)
define('FCPATH', dirname(__FILE__).'/');
exactly the part '/' makes problem to me.
in windows local, this code:

$path = FCPATH . $folder;
echo $path;

is generating something like:


And it's a problem. Easy way to correct this, is to use DIRECTORY_SEPARATOR instead of '/'.
But it isn't very good practice to edit index.php file.

Please give me an idea, what is the best to do...

While using DIRECTORY_SEPARATOR is the correct thing to do (and we'll do that in 3.0.6), I'm qurious to know what kind of a problem is that for you?
I haven't used Windows for a while, but don't remember ever having problems with forward slashes in my paths.
I don't see what DIRECTORY_SEPARATOR improves. In a quite customized system I use something like this:
// The variable $FCPATH variable is set in another file config.php at the same directory as of index.php
define('FCPATH', rtrim(str_replace('\\', '/', realpath($FCPATH)), '/').'/');
Never failed in Linux or Windows (XAMPP).
Of course that word "problem" is not used very well. Let's say "inconvenience".  Rolleyes

When I have been checked if directory exists like : if(isset($blabla))... I got wrong answer. But only on  XAMPP. 

Now, when narf answered my question greatly, i will edit index.php and I'll write @todo message form me and team. This way , nobody will forget.

Thanks for reply.