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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:49:12+00:00 2026-05-26T22:49:12+00:00

I am not an expert in PHP. I am trying to increase the use

  • 0

I am not an expert in PHP. I am trying to increase the use of include() to make my website code as clean as possible instead of just copying, for example, code of the header in all the pages. I have two questions

1 . Is it good practice to use include() a lot in terms of server requests, speed, …etc ?

index.php

(bunch of code)

  <? include("connect.php") ?>;

(bunch of code)

 <? include("header.php") ?>;

(bunch of code)

 <? include("footer.php") ?>;

2 . Is it fine also to use nested include’s()? example:

header.php
(some code)

<? include("searchFormInput.php") ?>;

now index.php will include header.php, then header.php will include searchFormInput.php as well
is this fine?

Thanks a lot

  • 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-05-26T22:49:12+00:00Added an answer on May 26, 2026 at 10:49 pm

    Yes, including is a common practice.

    Yes, including gives you slight performance penalty (very small).

    But including gives you readibility gain and thanks to it will be easier to employ DRY rule. Just remember the following:

    • if the file contains some code that should be executed only once (some setup, class definitions, function definitions etc.), use include_once() (it will have no effect if invoked again on the same filename),

    • if the file contains some code executed multiple times (eg. some template for a form), use simple include(),

    • if something is required for your application to work (eg. some security code, some setup etc.), use require() instead of include() or require_once() instead of include_once() – if the file will not be found, PHP will throw fatal error and will stop executing your script,

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

Sidebar

Related Questions

I'm trying to set up some exotic PHP code (I'm not an expert), and
I'm working on translating some php code to Python. I'm not an expert in
I'm not really debating which PHP framework to use as much as I'm trying
I'm not a php expert so I'm having some trouble trying to write a
I'm not php expert and I don't know what's the difference(1) between a and
i need to convert a Utf-16BE in ISO-8859-1 in PHP (i'm not an expert
I'm not expert about css menus. But I know basic system to make css
I'm trying to accomplish a fairly simple task for my website, but Im not
I am trying use a javascript function while passing php variables in it. For
I am trying use a javascript function while passing php variables in it. For

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.