I cant seem to make include to work in php
i'm trying to define a function in test.php
and i'm trying to link it to another file out side the test.php file directory what i tried so far is :
include ('../functions.php'); // Doesn't work
error message undefined -- functionname(); in test.php
include ('Doc\somethings\functions.php'); // Doesn't work
What worked for me is putting the whole link to define the functions ! ==>
includes ('F:\JF2\993\Doc\somethings\functions.php') // working but not Ideal ]
I read some devs have the same issue , they told them use this
include ($_SERVER["DOCUMENT_ROOT"] . "../../functions.php");
*Or Try to locate the file path using*
echo $_SERVER['DOCUMENT_ROOT']; // [ This Shows the root file path and it's not ideal for me ]
Output
F:\JF2\993\Doc\
am i missing something ?
test.php location
F:\JF2\993\Doc\somethings\scripts\test.php
functions.php location
F:\JF2\993\Doc\somethings\functions.php
additional info :-
Php 7.4
( i need to define a function from a file so i dont have to rewrite it again and again )
../functions.php?