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 8278095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:53:26+00:00 2026-06-08T08:53:26+00:00

I usually use this code below to include the page that I need into

  • 0

I usually use this code below to include the page that I need into the body of my website to include the page when clicking on a link.

<?php
        switch($_GET['page']){

            case '1':
            if(file_exists('main.php'))
            {
        include_once('main.php');
            break;
            }


            default:
        include_once('main.php');
            break;
            }
?>

but then I have to change this everytime i add a menu item by adding a case ‘2’ … etc
and now my question can this be written shorter/dynamically so that i just can add a link without having to change the piece of code everywhere?

ps: i did made it a little bit shorter.. but its still not good enough i think..

i also want to add this: i get my links from a ini file. i place it in there like this:

[navigation]
main.php = “Home”

if (!isset($_GET['page'])) {
      $_GET['page'] = 'main.php';

    }
    switch ($_GET['page']){
      case 'main.php':
      case 'about.php':
      case 'portfolio.php':
      case 'tips.php':
        $file = $_GET['page'];
        break;
      default:
        $file = '404.html';
    }
    include_once $file;

is it possible to get this too from the ini file?

  • 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-08T08:53:28+00:00Added an answer on June 8, 2026 at 8:53 am

    Try this:

    $page = isset($_GET['page']) ? $_GET['page'] : "main.php";
    if( file_exists($page)) include($page);
    else include("404.html");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For this code example below, usually I would use [self fall]; instead of the
When I select an element by name in Javascript, I usually use this code:
I usually use this: <html lang=en> . However, I am working on a website
Given that we use the code below Set paths = servletCtxt.getResourcePaths(/app/themes); How can we
I usually use this line to import file from out of the current folder
I usually use like this $ find -name testname.c ./dir1/dir2/testname.c $ vi ./dir1/dir2/testname.c it's
I usually use a boolean 'firstTime' like this: in C++: bool firsTime = true;
I have a coding/maths problem that I need help translating into C#. It's a
Take a look at this jsFiddle Code also listed below: window.MyView = Backbone.View.extend({ ticks:
I need to retrieve a web content. I usually use wget but it's giving

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.