CodeIgniter Forums
Defined constants - FCPATH - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Defined constants - FCPATH (/showthread.php?tid=64613)



Defined constants - FCPATH - Sezu - 03-12-2016

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.


RE: Defined constants - FCPATH - Narf - 03-12-2016

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?


RE: Defined constants - FCPATH - skunkbad - 03-12-2016

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


RE: Defined constants - FCPATH - ivantcholakov - 03-12-2016

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


RE: Defined constants - FCPATH - Sezu - 03-13-2016

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.