I inherited a PHP app that's been developed in Eclipse. While familiarizing myself with the code I noticed something odd. A little background. There are 2 code projects that share Common code. Each of these 3 are at the same directory level. The two projects have a softlink that points to common code. While reviewing various files, I noticed two different methods of including a file.
require_once 'common/utils/DatabaseClasses.php';
ahd
require_once '../common/utils/DatabaseClasses.php';
Is there a difference? Advantages/disadvantages? Eclipse will autocomplete the first method. Aside from that, I don't notice a difference. Also, there are no namespaces used in this app. Not sure if that's relevant here or not.
This is how the dirs/links are organized.
Project1
|------------- ../Common
Project2
|------------- ../Common
Common
From the manual there is a difference if you have set a
include_pathin your PHP configuration (php.ini file):require_once 'common/utils/DatabaseClasses.php';will try first to find the file in theinclude_pathif it is set, then in the script directory and last in the current working directory.If an absolute or relative path is used like in
require_once '../common/utils/DatabaseClasses.php';, theinclude_pathsearch will be ignored.So because the "generic"
commonfolder is out of the projects folders, there's a strong chance that theinclude_pathis set to its value, or else I don't see how these files would be included without pointing explicitly to it from the parent folder or from the root (as pointed in the comments). So I guess the first version is designed to point to the "generic" folder while the second points to the project's one. This is just a supposition, you have to check your configuration