Welcome Guest, Not a member yet? Register   Sign In
Defined constants - FCPATH
#1

Hi

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:

D:\xampp\docs\domain/orders

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...

Thanks.
Reply
#2

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?
Reply
#3

I haven't used Windows for a while, but don't remember ever having problems with forward slashes in my paths.
Reply
#4

I don't see what DIRECTORY_SEPARATOR improves. In a quite customized system I use something like this:
Code:
// 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).
Reply
#5

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB