# Include file inside an include file

**URL:** <https://forum.kirupa.com/t/include-file-inside-an-include-file/112329>\
**Category:** Uncategorized\
**Created:** [June 6, 2004, 8:13am UTC](https://forum.kirupa.com/t/include-file-inside-an-include-file/112329 "2004-06-06T08:13:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![da\_linuxguru](https://avatars.discourse-cdn.com/v4/letter/d/90ced4/32.png) [@da\_linuxguru](https://forum.kirupa.com/u/da_linuxguru)\
**Post date:** [June 6, 2004, 8:13am UTC](https://forum.kirupa.com/t/include-file-inside-an-include-file/112329/1 "2004-06-06T08:13:45Z")

</div>

Hello everybody,

Well, what I am trying to do is below:

I have three directories:

- 

- includes(dir)
- scripts(dir)
- realstuff(dir)

I have a class file and a details.inc.php file inside includes

- includes
  - connection\_class.php
  - details\_class.php

The connection\_class.php file uses the details\_class.php to get the login details so in the connection\_class.php file details\_class.php will be an include file on top with line include\_once("./details.inc.php");

If I create a new file called test.php in the same folder as the two files and include connection\_class.php in the first line include\_once(“connection\_class.php”); it works…

Now If I go to the scripts folder and create another file test2.php and include the file include\_once("…/includes/connection\_class.php"); it fails as connection\_class.php itself is looking for “./details.inc.php” file in the folder where it resides…

How can this issue be solved…I face the same problems when making templates and creating sub folders inside the main directory. The path to the images is lost…when the top\_inc.php file is called from whithin anothe directory.

I hope you guys understood what I am trying to say…

Thanks!  
da\_linuxguru
