I'm working on an app that has a tangled ball of wire going on as far as the number of "includes" that are represented. By that I mean, you'll have an index page that has a bank of "include('some_file.php') files in the header that will draw from directories that are three or four levels removed from the page you're looking at.
The problem is that on these included files, they're depending on JQuery libraries are not being seen because of the dynamic of the "include." For example...
index.php page - I'll have my JQuery library referenced in a "js" folder in the root directory.
an included file on that index page that has some JQuery as part of the syntax. But because it's looking for a JQuery library that's referenced as a relative URL on the
index.php page, the included file doesn't "see" it and it throws an error.
This is happening frequently and I've solved the problem by using a PHP script to retrieve the base URL and then build the correct web address so that I've got the equivalent to an absolute URL, but with the built in ability to move my app to a different server and not get in trouble.
My question is: Is there an more elegant way to do this? Does PHP have a function that establishes a dynamic where you don't wind up with broken links to various libraries once you start incorporating "includes" like what I've got described above?
What do you think?