-2

I have index.php file in directory My.

This file has including of file core/coreEngine.php

Inside coreEngine.php I try include another file config/test.php that is located on the previous directory:

index.php
/core/coreEngine.php
/config/test.php

I tried all cases:

require_once '../config/test.php';
require_once '../../config/test.php';
require_once '.../config/test.php';
Huligan
  • 419
  • 2
  • 6
  • 18
  • [Are PHP include paths relative to the file or the calling code?](http://stackoverflow.com/questions/7378814/are-php-include-paths-relative-to-the-file-or-the-calling-code) – FirstOne Jul 02 '16 at 15:08
  • Your directory structure is unclear to me, could you please [provide a graph](http://stackoverflow.com/a/3455675/4233593) – Jeff Puckett Jul 02 '16 at 15:09

1 Answers1

2
My/index.php
My/core/coreEngine.php <--- you are here
My/config/test.php     <--- you want to go here

You want to go back to My directory, so 2 directories back :

require_once '../../config/test.php';

BUT I strongly recommend to use absolute path instead of the relative one. You might want to use something like :

require_once($_SERVER['DOCUMENT_ROOT'].'/config/test.php');
Hearner
  • 2,711
  • 3
  • 17
  • 34