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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:50:33+00:00 2026-06-11T16:50:33+00:00

When including other files in your PHP scripts, what is faster for webserver to

  • 0

When including other files in your PHP scripts, what is faster for webserver to process:

include 'http://www.mydomain.com/bin/scripts/thescript.php';

OR

include '/home/user/public_html/bin/scripts/thescript.php';

OR

include '../../scripts/thescript.php';

OR is there really no practical difference in the real world?

This is not an academic question. If all three methods are equally satisfactory in real time, please tell me. That’s all I need to know.

  • 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-11T16:50:34+00:00Added an answer on June 11, 2026 at 4:50 pm

    Absolute, i.e. strating with “/” is always better. That way if you move your app you don’t have to manually update the path names. I use a combo of 2 functions to define the absolute path as a constant.

    function tsl($path) {
        if (substr($path, strlen($path) - 1) != '/'){
            $path .= '/';
        }
    }
    function get_root_path() {
      $pos = strrpos(dirname(__FILE__),DIRECTORY_SEPARATOR.'inc');
      $adm = substr(dirname(__FILE__), 0, $pos);
      $pos2 = strrpos($adm,DIRECTORY_SEPARATOR);
      return tsl(substr(__FILE__, 0, $pos2));
    }
    define('ROOTPATH', get_root_path());
    

    I am using inc/ in my example, but you can change this. This will allow you to just use the constant ROOTPATH rather than trying to figure out the path evertime.

    Another way is like this…

    <?php
    define('ROOT_DIR', dirname(__FILE__));
    define('ROOT_URL', substr($_SERVER['PHP_SELF'], 0, - (strlen($_SERVER['SCRIPT_FILENAME']) - strlen(ROOT_DIR))));
    ?>
    

    Just include the file with these defines in your template page.

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

Sidebar

Related Questions

Possible duplicate of: should-i-link-to-google-apis-cloud-for-js-libraries also many other discussions, including: Where do you include the
In regards to the above and/or including other methods, if you are searching for
I'm planning to localize my iPhone app, including 9 other languages, besides English. My
I've looked around StackOverflow and other places (including Git documentation) and just cannot get
Is there a way to do so including creating an other build-markup function ?
when including libraries c, the line does not end with a semicolon, while other
I've been googling various different things including spring taglib form spring form:checkboxes and other
I commited (not pushed) a lot of files locally (including binary files removing &
Android 3.2. Attempting to use Switch (http://developer.android.com/reference/android/widget/Switch.html) in my project. Switch.class is not found
my jquery code not run with IE6 but runs all others including IE7. It

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.