PHP how to include file from parent directory relative path

If You have an Android project web in PHP code, you can to try this code for including file from parent directory:

Example source code:

// from parent dir
include "./myIncludeFile.php";
 
 
// from parent dir
include __DIR__."/../myIncludeFile.php";
 
// from parent dir or count of slash like as directories count
include substr(__DIR__,0,strrpos ( __DIR__ , "/")).'/myIncludeFile.php'; 
 
 
// from PARENT/parent/
include "./../myIncludeFile.php";
This entry was posted in PHP and tagged , . Bookmark the permalink.


Comments are closed.



2,870 views