# Relative include feedback

- Thread: https://externals.io/message/15
- Original archive: https://news-web.php.net/php.internals/15
- Started by Kelvin Jones on 2003-03-13T16:24:16+00:00
- Messages: 7
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #15 — Kelvin Jones — 2003-03-13T16:24:16+00:00

URL: https://externals.io/message/15#15

I hope that this is an appropriate place to post a feature request!

I posted a message on the Zend.com "into the future" forum about having 
a function that would return the full path to a file relative to the 
current executing script, and NOT the first script called, i.e.:

Instead of doing:

include_once realpath(dirname(__FILE__).'/../example.php');

As you have to do now, you could do:

include_once relative_path('../example.php');


What do you think?


Regards,

Kelvin

---

## #16 — Hartmut Holzgraefe — 2003-03-13T16:27:42+00:00

URL: https://externals.io/message/15#16 · In reply to: #15

Kelvin Jones wrote:
> include_once realpath(dirname(__FILE__).'/../example.php');

what do you need the `realpath()` call for?
(that's already taken care of internaly in the *_once() functions)



-- 
Six Offene Systeme GmbH     http://www.six.de/
i.A. Hartmut Holzgraefe     Email: hartmut@six.de   Tel.: +49-711-99091-77

Sie finden uns auf der CeBIT in Halle 6/H44   http://www.six.de/cebit2003/

---

## #17 — Derick Rethans — 2003-03-13T16:28:01+00:00

URL: https://externals.io/message/15#17 · In reply to: #15

> I hope that this is an appropriate place to post a feature request!
> 
> I posted a message on the Zend.com "into the future" forum about having 
> a function that would return the full path to a file relative to the 
> current executing script, and NOT the first script called, i.e.:
> 
> Instead of doing:
> 
> include_once realpath(dirname(__FILE__).'/../example.php');
> 
> As you have to do now, you could do:
> 
> include_once relative_path('../example.php');
> 
> 
> What do you think?

Just set your include path correctly?

Derick

-- 
                                        "my other box is your windows PC"
-------------------------------------------------------------------------
 Derick Rethans                                 http://derickrethans.nl/ 
 PHP Magazine - PHP Magazine for Professionals       http://php-mag.net/

---

## #18 — Hartmut Holzgraefe — 2003-03-13T16:31:52+00:00

URL: https://externals.io/message/15#18 · In reply to: #16

Hartmut Holzgraefe wrote:
> Kelvin Jones wrote:
> 
> > […]
> 

BTW: don't we have __DIR__ by now?


-- 
Six Offene Systeme GmbH     http://www.six.de/
i.A. Hartmut Holzgraefe     Email: hartmut@six.de   Tel.: +49-711-99091-77

Sie finden uns auf der CeBIT in Halle 6/H44   http://www.six.de/cebit2003/

---

## #19 — kelvin@kelvinjones.co.uk — 2003-03-13T16:44:58+00:00

URL: https://externals.io/message/15#19 · In reply to: #18

__DIR__ would be cool.

Do other functions that take filename parameters also expand the paths? i.e.: 
 `fopen()` ..etc.

If they do, then maybe there isn't a need for a function as long as there's a 
__DIR__ constant to easily get the current directory.

Quoting Hartmut Holzgraefe <hartmut@six.de>:

> Hartmut Holzgraefe wrote:
> > […]
> 
> BTW: don't we have __DIR__ by now?
> 
> 
> -- 
> Six Offene Systeme GmbH     http://www.six.de/
> i.A. Hartmut Holzgraefe     Email: hartmut@six.de   Tel.: +49-711-99091-77
> 
> Sie finden uns auf der CeBIT in Halle 6/H44   http://www.six.de/cebit2003/

---

## #52 — Daniel Lorch — 2003-03-15T00:56:42+00:00

URL: https://externals.io/message/15#52 · In reply to: #17

hi,

> > […]
> 
> Just set your include path correctly?

I don't think that was his point. If file A includes file B and file B in-
cludes another file, say file C, then file C will be included with the re-
lative path of file A (and not file B as expected).

-daniel

---

## #67 — kelvin@kelvinjones.co.uk — 2003-03-17T09:32:04+00:00

URL: https://externals.io/message/15#67 · In reply to: #52

That's right.
And not only that.. not all people have access to set things like the include 
path themselves, and would have to do it in every script they run using ini_set
().
And just because there's a workaround for a problem, doesn't mean we can't 
provide a better solution.

Kelvin

Quoting Daniel Lorch <daniel@lorch.cc>:

> hi,
> 
> > […]
> 
> I don't think that was his point. If file A includes file B and file B in-
> cludes another file, say file C, then file C will be included with the re-
> lative path of file A (and not file B as expected).
> 
> -daniel
