Jump to content

Lots of different files or a switch statement?


seabro

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.