I'm new here so first i would like to say hello to everyone :)
I have been learning PHP for the past year on and off and have built a fully pledged website. Since my website first launched it has progressed into a full membership system which i love as it was part of my learning curve.
Since then i have obviously learned allot more about PHP althou i would still say i am not a pro or anything as i say i been learning on and off due to issues beyond my control so i could not learn as much as i wanted to.
Anyway, i basically want to re develop the backend of my live website. To ensure it goes well i am redoing the backend of the site on my computer using XAMPP etc. As since i started to learn i know know from learning that i could improve majority of my code. Security wise i am happy with as i always made sure i learnt that at the begging, i mean just doing code cleanup.
Basically i am not sure how to go about it.
i use includes obviously so i can make updates via one file. Problem is i am not sure how to proceed.
my pages when i create them for my website have a structure template like:
<!-- Include top.inc.php --> <?php require_once("".$_SERVER['DOCUMENT_ROOT']."/inc/top.inc.php"); ?> <!-- Meta Description --> <meta name="description" content="" /> <!-- Keywords --> <meta name="keywords" content="" /> <!-- Page Title --> <title></title> </head> <!-- Include main.inc.php --> <?php require_once("".$_SERVER[DOCUMENT_ROOT]. "$main_inc"); ?> <!-- Include menu.inc.php --> <?php require_once("".$_SERVER[DOCUMENT_ROOT]. "$menu_inc"); ?> <!-- PLACE WEBSITE CONTENT HERE --> <!-- PLACE WEBSITE CONTENT HERE END --> <!-- Include footer.inc.php --> <?php require_once("".$_SERVER[DOCUMENT_ROOT]. "$footer_inc"); ?>
Now problem i got is each page i create needs the top.inc include path but the others don't as the top.inc.php has an include to paths.inc.php that contains site paths for things like main.inc.php and other paths across the website.
Basically i am trying to create my website so i can avoid includes in my webpages i create so when and if i do change server and/or path(s) i only have to change it in one place. Problem is as i got an include for top.inc.php in my webpage template that i use to create my webpages it means if i ever change the path etc i have to manually edit every page.
I am really not sure how to proceed.
Should i keep my paths.inc.php (which contains paths for website) or is there a better alternative way?
At the moment all my files that are needed on different page like website paths, website name, address etc i have placed in includes in the top.inc.php . Problem is my functions.php file for example has an authentication function, i cannot include this in top.inc.php because it needs to go before top.inc.php so it can exit script before it loads page. This means i would be putting another include in my webpages which means if i change paths etc i will have to change each webpage indvidually.
I am so confused how to go about my includes and paths etc.
If anyone could explain to me how they do it and an efficent way i would be so grateful as this is causing me delay on not being able to start my re-programming of my website.
Truth of the matter is without confusing you anymore as i probably not explained it in simple terms is how do you go about your includes, paths etc?
Edited by phplover: n/a