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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:40:49+00:00 2026-06-13T10:40:49+00:00

My question is regarding the php function include(); Is it okay to include one

  • 0

My question is regarding the php function include();

Is it okay to include one main php file to store all variables, functions, queries etc.. and from within the html, tag in and out of php for the function and variables needed?

I feel this would keep my html still looking pretty but I’m not sure of it’s efficiency.

config.php

<?php
$username = 'foo';
function getPoints(){};
mysqli_query(,);

So basically index.php would be

<?php include('config.php') ?>
<hmtl>
<head></head>
<div id="ui"><? echo $variable?></div>
<body></body>
</html>
  • 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-13T10:40:50+00:00Added an answer on June 13, 2026 at 10:40 am

    I am not sure whether I properly understood what you are trying to achieve, but since the application seems pretty simple (and you do not need complex solutions), keeping the actual business logic separated from the presentation (HTML code) is completely okay.

    So in fact you may have two files like that:

    • index.php (your “HTML”),
    • library.php (your business logic),

    and in this case it should be very efficient. Of course unless you will break something, but this is not connected to the structure itself 😉

    The nature of PHP allows it to be embedded in HTML, but do not overdo it. Keep your logic as separated as possible from the presentation – preferably define every function / class / variable in library.php, and only use the results when displaying in index.php.

    Also keeping such structure, with code in one place avoids the overload that could be introduced by autoloading (finding files, determining where to find specific class etc.). Some even optimize their code by putting it all in one place (“compiling”).

    Later in the learning process you will probably need to learn some framework, that will take different approach. But you probably do not need it right away 😉

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

Sidebar

Related Questions

I have a question regarding the variables/arrays used in PHP functions. After executing the
I have a question regarding static function in php. let's assume that I have
This question is regarding getopt function in php. I need to pass two parameter
I have a question regarding php and opening files PHP has more than one
Quick question regarding __callStatic() in PHP; class Test{ public static function __callStatic($method, $arguments){ echo
I have a question regarding the php validation, I have this script $(document).ready(function(){ //
I have a question regarding reading an xml file with php. I have a
I have a question regarding the proper way to modify a php DateTime object.
I am using smarty tags with php and my question / issue is regarding
Question regarding GtkBuilder. When we unref builder pointer does it destroys all the screens/widgets

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.