Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8584919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:53:16+00:00 2026-06-11T21:53:16+00:00

I am creating a site where different account types will be shown a different

  • 0

I am creating a site where different account types will be shown a different version of each page. I have it working, but my question is in terms of speed / “best practices”. Which of the following (or something completely different) would be the best way to do this?

Option 1. Break each account type into individual sections of the file:

if($accountType == "type1"){
  //All lines of code for the account type1 page
}
elseif($accountType == "type2"){
  //All lines of code for the account type2 page
}
elseif($accountType == "type3"){
  //All lines of code for the account type3 page
}

Option 2. Break each account type into sections of the file using include files:

if($accountType == "type1"){
  //this file has all of the code for account type1 page
  require('includes/accounts/type1/file.php');
}
elseif($accountType == "type2"){
  //this file has all of the code for account type1 page
  require('includes/accounts/type2/file.php');
}
elseif($accountType == "type3"){
  //this file has all of the code for account type1 page
  require('includes/accounts/type3/file.php');
}

Option 3. Use lots of conditional statements throughout the file to generate the page for each account type:

if($accountType == "type1"){
  $result = mysql_query("//sql statement for account type1");
}
elseif($accountType == "type2"){
  $reslut = mysql_query("//sql statement for account type2");
}
elseif($accountType == "type3"){
  $result = mysql_query("//sql statement for account type3");
}
while ($row = mysql_fetch_array($result)) {
  $variable1 = $row['variable1'];
  if($accountType == "type1"){
    $variable2 = $row['type1Variable2'];
    $variable3 = $row['type1Variable3'];
  }
  elseif($accountType == "type2"){
    $variable2 = $row['type2Variable2'];
  }
  elseif($accountType == "type3"){
    $variable2 = $row['type3Variable2'];
  }
  $variable4 = $row['Variable4'];
}
echo "The variables echoed out are $variable1, $variable2";
if($accountType == "type1"){
  echo ", $variable3";
}
echo "and $variable4";
//the rest of the file to follow in the same way

Basically it comes down to this:

Option 1: the file is 1000 lines of code.
Option 2: the file is 30 lines of code, and each include file is between 250-350 lines of code.
Option 3: the file is 650 lines of code. It is less because some of the code can be ‘shared’ between all three account types.

Which option would be the fastest / “best practice”? I am leaning toward option 3 because overall file size would be smaller, but there are a lot more conditional statements with this option (option 1 and 2 only would have three conditional statements, whereas option 3 would have 40 for example). Does having this many more conditional statements make the file process slower? Is there actually any difference between option 1 and option 2 (does separating the blocks of code into include files mean that it will only load one include file per account type? Or does php load all three files and just choose the proper one?)?

Thanks for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:53:17+00:00Added an answer on June 11, 2026 at 9:53 pm

    In terms of efficiency, Option 3 would be the slowest as it would have more conditional-checks than any other – however, the speed would be very (very) negligible.

    To define the “best practice” would be impossible – it really comes down to “what will be the easiest for you and who-you-work-with to maintain”. If, down the road, you have to make massive changes to the code but only for $accountType == "type2", do you want to go through a ton of spagetti code (Option 3), or a bit more separated-into-blocks (Option 1), or just open the specific file for that type (Option 2)?

    In my personal opinion, even without using OOP/MVC-framework practices, I would recommend Option 2. Splitting each individual type into their own separated files will save you a lot of headaches in the future if you need to update anything. You can even merge certain parts – for instance, if all three types have one “block” that has all of the same look & feel, you can define that in it’s own include and include it in all three of the types’-files.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a site who's users will include customers and different levels of Admins.
I am creating a site and want to have individual pages for each row
I am creating a site on which content will be stored for several different
I'm going to be creating competitions on the current site I'm working on. Each
I am creating a site which will have a desktop and a mobile theme.
I am creating a site for me only that will run from my server.
I'm writing a site in ASP.NET MVC that will have user accounts. As the
I am creating a site where users can save different credentials and while logging
I am creating a site where each registered user can store a list of
We are using Smarty Templates on our LAMP site but my question would also

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.