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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:58:55+00:00 2026-06-02T15:58:55+00:00

I have a habit of using include() a lot in my php scripts. I

  • 0

I have a habit of using include() a lot in my php scripts. I would like to know is it a good approach. I just use include a lot because it makes code look-better for future-proof programming.

  • 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-02T15:58:56+00:00Added an answer on June 2, 2026 at 3:58 pm

    make use of php autoloading function

    example:

    function __autoload($class_name) {
        include $class_name . '.php';
    }
    

    whenever you instantiate a new class. PHP automagically calls the __autoload function with one argument i.e the class name. consider the below example

    $user = new User():
    

    when you instantiate the user object here the autoload function is called, it tries include the file from the same directory. (with reference to above autoload function). now you could implement your own logic to autoload classes. no matter in which directory it resides. for more information check out this link http://in.php.net/autoload.

    Update:
    @RepWhoringPeeHaa, you said it correct buddy. there are more benefits in using spl_autoload then simple autoloading function. the major benefit i see is that more than one function can be used or registered.

    for example

    function autoload_component($class_name) 
    {
        $file = 'component/' . $class_name . '.php';
        if (file_exists($file)) {
            include_once($file);
        }
    }
    
    function autoload_sample($class_name)
    {
        $file = 'sample/' . $class_name . '.php';
        if (file_exists($file)) {
            include_once($file);
        }
    }
    spl_autoload_register('autoload_component');
    spl_autoload_register('autoload_sample');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I've gotten in the habit of using WPF/C# value converters because they are
I'm coming from predominantly using VIM for everything, and so I have a habit
I have an HTML file and would like to extract the text between <li>
In JavaScript I have a habit of using the following fallback evaluation var width
I have a bad habit of using the cursor keys of my keyboard to
I have a bad habit of using the 'home' key to go back to
I have the habit (?!?!?) of returning everything as a const value. Like this...
I have a habit of hardcoding URLs into my HTML: ...<a href=www.mySite.com/login>logon to your
Some of the developers on the project I work on have a habit of
Coming from C/C++ a long time ago I still have a habit of ensuring

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.