Hello, I am new to PHP so I'm trying to struggle through this issue. I have taken over a site in which the previous developer didn't believe using a directory structure to keep files neatly organized - 90% of the pages in the site are all in the main directory. One of my goals is to clean this up by creating subdirectories for like files.
They did create a /includes/ directory where all the nav items reside, but it's set up so that when the files are included, again everything is in the main directory. As soon as I move some files down a level it breaks. I have links to js, css and images files all over the place and there will be various levels of directories.
Long story short I am going to replace all the current include code
with this code
Problem is on the dev server the files are not in the root, but down 1 level. In production they are down 4 levels. I was thinking I could create a global variable, based on the server name, of the directory structure and add that to my include statement:
I don't want to define what DIRPATH is going to be in every single page - it won't ever change unless they get a new web master.
SO...is there a way to put a global variable into memory once and have it stay there? Kinda like an application-level variable (I'm also a ColdFusion developer, and they have something like this).
Thanks in advance!
They did create a /includes/ directory where all the nav items reside, but it's set up so that when the files are included, again everything is in the main directory. As soon as I move some files down a level it breaks. I have links to js, css and images files all over the place and there will be various levels of directories.
Long story short I am going to replace all the current include code
Code:
<? include "includes/navbar.php"; ?>
Code:
<? include "/includes/navbar.php"; ?>
Code:
<? include DIRPATH."/includes/navbar.php"'
SO...is there a way to put a global variable into memory once and have it stay there? Kinda like an application-level variable (I'm also a ColdFusion developer, and they have something like this).
Thanks in advance!