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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:53:54+00:00 2026-06-18T10:53:54+00:00

This has been on my mind for quite some time and I figured I

  • 0

This has been on my mind for quite some time and I figured I should seek an answer from experts.
I want to know if it is a poor programming technique to funnel all PHP requests through a single file. I have been working on a website and not sure if it will scale with growth because I am not 100% certain of how PHP handles the include() function.

To better explain how I have build my quasi framework here is a snippet of my root .htaccess file:

# > Standard Settings
RewriteEngine On

# Ignore all media requests
RewriteRule ^media/ - [L]

# Funnel all requests into model
RewriteRule ^(.*)$ _model.php [QSA]

So everything except content within the media directory is passed into this single script.

Inside _model.php I have all my input sanitisation, user authentication, session data gets pulled from the database, any global variables (commonly used variables like $longTime, $longIP etc…) are set. Requests are routed via interpreting the $_SERVER["REQUEST_URI"] variable.

Essentially I have a switch() statement which chooses which module to include(). What I don’t understand is: when PHP executes, will it execute every single include() regardless of whether or not the case directive is true?

I am concerned that after time I will have a lot of these modules – and if PHP does at runtime include all the modules it will end up occupying too much processing power and RAM…

—

Edit:
I am really just asking if PHP will ‘read’ all those files that it potentially might have to include. I know that it shouldn’t actually execute the code.
If one of my include() is a 2GB file which takes a long time to process, will PHP always read over that file before executing?

—
Edit:
I have found another similar question (I did search a lot before posting this one)
PHP behavior of include/require inside conditional

I think I can close this off.

  • 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-18T10:53:56+00:00Added an answer on June 18, 2026 at 10:53 am

    No, PHP will execute include in the moment the code fragment is reached.

    This is quite important, because you can have php include file with code directly. E.g.

    File1:

    <?php echo "Foo"; ?>
    

    File2:

    <?php
      echo "Before";
      include("File1");
      echo "After";
    ?>
    

    Sometimes your PHP processor won’t even know at compiletime which file to include. Imagine something like include("File".mt_rand(1,10));. PHP won’t know the filename to include up to the very moment it reaches the include statement.

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

Sidebar

Related Questions

This algorithm has been in my mind for a long time, but I cannot
I've been a web developer for quite some time and what has helped me
This has been bothering me lately- when I use some code like below to
This has always been on my mind while programming, so I thought I'd spit
i know this has been asked here . But my question is slightly different.
Ok, I know this has been asked a thousand times before, but no conclusive
This has been playing on my mind for a while, I need to check
This topic has been on my mind the last little while and I have
I know this has been covered in in various questions and all over the
I know this has been covered extensively, but I can't seem to find an

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.