Welcome Guest, Not a member yet? Register   Sign In
Question about how PHP resolve current directory (".")
#1

[eluser]ang89[/eluser]
Hi there!

My question is straightforward, but I do have something to explain. Please jump to the last paragraph if you don't want to bother my whole coding epics.

In CodeIgniter, when I try to resolve current directory by using realpath("."), I always got the directory in which the gateway index.php is located (in my case, /webroot). Regardles the location of current file (model, controller, config, library), it's all the same.

But I came to a problem where I have to create another controller from within a library (I can explain why if you would like to know, but I think it's not important here). And from within the controller class, I have the following:

Code:
<?php

class Test_service extends Controller
{
    public function __construct()
    {
        $CI =& get_instance();
        $CI->firephp->log('The path inside Test_service controller: ' . realpath('.'));
        parent::__construct();
    }
}

Surprisingly, it outputs the location in which the file is located (/application/controllers/services), not the /webroot !.
And the parent::__construct off course gives an error because ... well, if you follow the trace you can find an include_once(APPPATH.'config/autoload'.EXT) inside Loader class.

After a long and maybe irrelevant explaination, and my question is, how does PHP resolve current directory (".")? I thought it should be the directory of the first file in the chain of execution (index.php) ?


Messages In This Thread
Question about how PHP resolve current directory (".") - by El Forum - 04-16-2010, 10:48 AM
Question about how PHP resolve current directory (".") - by El Forum - 04-16-2010, 12:14 PM
Question about how PHP resolve current directory (".") - by El Forum - 04-16-2010, 02:14 PM



Theme © iAndrew 2016 - Forum software by © MyBB