Q:

include_once(../../config.php): failed to open stream: No such file or directory

My Files Path like >>
/config.php
/fold_1/fold_2/functions.php
/fold_1/myfile.php

functions.php contain >>
include_once("../../config.php");
function addition($x,$y){return($x+$y);}
function substraction($x,$y){return($x-$y);}

myfile.php contain >>
include_once("fold_2/functions.php");
call addition(2,3);

but it gives warning like >>
include_once(../../config.php): failed to open stream: No such file or 
directory 

i know the reason is like when i include function.php in myfile.php it will replace all code of function.php to myfile.php and then run the code of function.php so it can't able to find the config.php file at ../../config.php
but i wan't to know is there any solution (solution means changing some variables value in php.ini or like that) to overcome this problem so it can run the code of functions.php first and after it will mapped to the myfile.php 

A:

try using like this:
include_once $_SERVER['DOCUMENT_ROOT']. '/path/to/config.php';

sometimes PHP and the server prefer full absolute paths rather than ../../ - I usually fix using $_SERVER 

