I have taken over managing someone's site after giving myself a PHP crash course, and the folder structure and coding is horrific!
The worst part is that the original programmer wasn't much better than I at handling subfolders, so they pretty much hard coded all links with the complete server path, and I'm trying to clean that up.
The problem I am running into is that PHP seems to always start the path to a folder from the original PHP file and to ignore any other paths that includes are in.
Example:
Start page:
site.com/index.php
Includes folder:
site.com/includes/
Pictures folders:
site.com/images/... (with sub folders)
So far no problem, but the site also has subfolders, e.g.:
site.com/products/index.php
which accesses the same include files.
Also no problem - except that now all the paths that are listed in the include files are one folder off, especially the picture paths.
What is the standard solution for this type of situation where the includes and images stay in the same folder but the PHP files that are directly linked to switch between different sub folders?
I stumbled across this solution:
Code: Select all
// SET PATHS FOR INCLUDE FILES
$_PATHS["base"] = dirname(__FILE__) . "/";
$_PATHS["includes"] = $_PATHS["base"] . "includes/";
ini_set("include_path",
"$_PATHS[includes]");
// END PATHS
I bet for a professional this is a fairly easy one, so hopefully someone here has an answer for me.
Thanks so much in advance!