seabro Posted October 5, 2013 Share Posted October 5, 2013 Hi all, I am a bit of a PHP rookie, never having had any training so I don't really know the best practices. In the past I have made sites out of lots of different files and more recently I made a whole site in a single index.php which had lots of options in a switch statement. The single file site was really messy as you can imagine. What's the norm? How do you guys find the right balance? Thanks! Seabro Link to comment https://forums.phpfreaks.com/topic/282731-lots-of-different-files-or-a-switch-statement/ Share on other sites More sharing options...
_EmilsM Posted October 5, 2013 Share Posted October 5, 2013 I mostly use seperate files with seperate directories for file types, for example, classes or functions, template. Then I can easily tell where what is and can find what I want. Another thing I do is name files according to the content, so I can tell witch file coresponds to what. Link to comment https://forums.phpfreaks.com/topic/282731-lots-of-different-files-or-a-switch-statement/#findComment-1452685 Share on other sites More sharing options...
davidannis Posted October 8, 2013 Share Posted October 8, 2013 I generally like to have a few common files sets globals, opens db connections, etc header footer functions that are used by multiple programs then I have separate files and include the common ones. Link to comment https://forums.phpfreaks.com/topic/282731-lots-of-different-files-or-a-switch-statement/#findComment-1453171 Share on other sites More sharing options...
udaystrad Posted October 12, 2013 Share Posted October 12, 2013 People have different style for making a website, u can make it the way u want. All pages are linked together in some way. Usually people follow a common style so that their fellow patners or the next person handling it can understand the flow and that is as follows:- 1. Home page is named as index.php (.php extension is a page made in php, u can use any language or say file extension u want) 2. if u have a commom header and footer for all pages then header.php and footer.php respectively. 3. Pages are named after their purpose, for eg. Contact page -> contact-us.php , About Us page -> about-us.php , Terms of service -> tos.php , etc. 4. All images are saved in Images or Img folder, CSS files is saved in CSS folder, Javascript in js folder Again u can name the files the way u want. But the above way helps everyone to understand and easily remember wer ur files are. Link to comment https://forums.phpfreaks.com/topic/282731-lots-of-different-files-or-a-switch-statement/#findComment-1453645 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.