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

  • SEARCH
  • Home
  • 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 8932501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:19:44+00:00 2026-06-15T09:19:44+00:00

I have a lot of php file. To access each php I am using

  • 0

I have a lot of php file.

To access each php I am using parameter.

Example : index.php?route=changepassword, index.php?route=aboutus, etc

I have a route.php to link the parameter to the correct file

Its better to use

If-Else statement

$route = $_GET['route'];
if ($route==changepassword) {
   //statement
} else if ($route==aboutus) {
   //statement
}

of using switch-case ?

$route = $_GET['route'];
switch ($route) {
case "changepassword" :
   //statement
   break;
case "aboutus" :
   //statement
   break;
}

This is just 2 file, I have 10+ file, it is better to use what?

  • 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-15T09:19:46+00:00Added an answer on June 15, 2026 at 9:19 am

    You should use an array-map wherever you can:

    $map = array(
        "changepassword" => "includes/changepw.php",
        "aboutus" => "templ/aboutus.php",
    );
    

    In that simple case (you didn’t elaborate on your //statements) you can just utilize them as:

    incude( $map[$_GET["route"]] );
    

    As commonly you can map them onto classes or callbacks, or anonymous functions.

    But lastly a map is more concise and easier to maintain.

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

Sidebar

Related Questions

I have a PHP file that contains a lot of if and else statements
I have read a lot of articles on developing classes (I am using php),
I have heard a lot that PHP is slow compared other languages. Is the
I have a very large script which contains a lot of php files, so
I need help with preg_match function in php. I have read a lot of
I have a php web application that uses big cookies to store a lot
Possible Duplicate: php false place in condition I have noticed that a lot of
I have a php webapp convention that I'd like to follow and a lot
I have a PHP based web application which is currently only using one webserver
I have a php file with around 100mb which is full of arrays (only

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.