I realized I used a particular function over and over again in my PHP files, so I took the function out of all of them and put it in a seperate PHP file and included it where I need it.
Now when I make updates to the function, all the files that use it get updated. Great.
Now there is just one problem, the function itself uses relative URLs, and when you include the PHP the files are relative to the calling PHP, not the included's PHP directory. I know the quick and dirty answer is to use absolute links, but how can I get the included PHP to reference things to ITSELF and not to the PHP that called it.
Example:
index.php includes a file called create_table.php..... create_table.php echoes CSS and javascript to index.php. The CSS and javascript are in the same directory as create_table.php, but when using src="javascript.js" it wants to find the javascript.js where index.php is located, not where create_table.php is located.
Edit: how the structure works
/includes/create_table.php
/includes/style.css
/includes/javascript.js
/test/dir/1/2/3/index.php
So when I attempt to use src="javascript.js" instead of looking for /includes/javascript.js it tries to find /test/dir/1/2/3/javascript.js