Login Register


I shouldnt have to rewrite this filter_list
Author
Message
I shouldnt have to rewrite this #1
Code:
require '../8/db.php'; include '../8/k.php'; include '../8/l.php';
every time I want to require or include i have to manually write "../8/" which I shouldn't have to do in my development process.

There are 3 sites that use the same code base, but have their own files too.
To get to the common code base I have to go up one folder and into the 8 folder.
The real problem is that the file that hosts the above code is in the same folder as the rest of those files, but it looks like the relative path is based off of the site file. How do I fix this issue? It's annoying

Reply

RE: I shouldnt have to rewrite this #2
The first thing I tend to do when I start a new project is make a centralized configuration file with every function and every file that I need to include inside of that and just require that. You can also get around adding this to like a billion different files by using the PHP switch statement and rather than going to index.php you can just use "home?p=index". Just make sure the files you include in switch are non-functional without the configuration file, or in a non-readable folder.

Spoiler: example
example 1 - index.php
[Image: GBm9rLF.jpg]

example 2 switch.php
[Image: 3lxhzeF.jpg]

[+] 1 user Likes BlueScreen's post
Reply

RE: I shouldnt have to rewrite this #3
But I don't need all resources on all pages.

Reply

RE: I shouldnt have to rewrite this #4
(09-13-2015, 04:00 PM)SilkSnake Wrote: But I don't need all resources on all pages.

If there's something that you're only going to use on a couple of pages I guess you could just include it inside of the case itself. Still better than having to go from file to file having to paste it and change all of them the next time you modify the folder structure. As for anything else that is used on all pages, include that in the global configuration file.

[Image: aDV9CyG.jpg]

[+] 1 user Likes BlueScreen's post
Reply

RE: I shouldnt have to rewrite this #5
I guess I will have to build out my website more to understand how switch cases can be useful.

Reply







Users browsing this thread: