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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:10:27+00:00 2026-05-12T18:10:27+00:00

If I can ask that answers refrain from pointing towards frameworks or other libraries,

  • 0

If I can ask that answers refrain from pointing towards frameworks or other libraries, I would appreciate it. I am aware of those, and am after more of an answer based on experience for quick little hacks.

Start with some base html

 <html>
      <head>
           <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
           <title>Page Title</title>
      </head>
      <body>
         // something is going to happen here, could be more html, or php
      </body>
 </html>

Let’s say you will have hundreds of pages, of course, you want to modularize this in a way to have less code duplication.

I have seen, used, and debated many a tactic.

The basic includes method:

header.inc.php

 <html>
      <head>
           <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
           <title>Page Title</title>
      </head>
      <body>

footer.inc.php

      </body>
 </html>

The stub of all of your hundreds of php pages:

<?php include 'header.inc.php'; ?>
    // html or other php can go here
<?php include 'footer.inc.php'; ?>

Get a little more fancy, and have a var.inc.php and you could set $page_title and have that in front of the first include, saving the time of editing it out of hundreds of pages.

The functions method:

show.inc.php

function display_header($page_title) {
     echo "
     <html>
          <head>
               <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
               <title>$page_title</title>
          </head>
          <body>";

}

You do the same for the footer, I suspect you get the idea. I know a lot of you are thinking objects at this point, which I would like to also avoid for this discussion.

Consider you are trying to teach a very young kid some principles, or that you are trying to get a designer to move into some form of the modern age.

Which either method, you start to run into cases where you are going to look at the output of the html and php in a browser. There is a very clear tab indention and structure to the source output that hits the browser. And most of the time, looking at the source of a site, I see html that is pretty abysmal. All one line, or varying forms of indenting.

How in a simple way do you solve this?

That display_header() function is going to spit in \t’s all over the place, or spaces, depending on your editor, that are going to make the rendered output a mess.

There is this option:

function display_header($page_title) {
    echo '<html>';
    echo '<head>';
    echo "\t" . '<meta http-equiv="Content-type" content="text/html; charset=utf-8" />';
    echo "\t" . '<title>' . $page_title . '</title>';
    echo '</head>';
    echo '<body>';

}

Then, you get into cases of:

 echo '<table>';
 foreach ($variable as $item) {
      echo '<tr><td>' . $item . '</td></tr>';
 }
 echo '<table>';

versus

 echo "\t" . '<table>' . "\n";
 foreach ($variable as $item) {
      echo "\t\t". '<tr><td>' . $item . '</td></tr>' . "\n";
 }
 echo "\t" . '<table>' . "\n";

And now, you have just really made a mess of your php. So I start thinking output buffers, and I am going to totally freak the designer out with that concept. But I have just mixed more html with php that I would be proud of.

And I honestly have never been able to settle up with this stuff:

<?php foreach ($variable as $item) { ?>
 ....
<?php } ?>

Both yields much better generated html, but to me, it also yields a more complex php file. Pretty basic question, I am sure there will be some strong opinions, and a desire to push towards frameworks and OOP. I understand those methods, but again, am looking for best suggestions looking at giving some tools to a person who is never going to have a passion for programming, and just wants to get stuff done, in a way that will help them be efficient.

  • 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-12T18:10:28+00:00Added an answer on May 12, 2026 at 6:10 pm

    Forget about the indentation of HTML output when writing PHP. Otherwise you’re spending far too much time worrying about something completely trivial.

    If you need to clean up the HTML output to make it easier for a designer to read, run it through Tidy. If this seems inefficient, remember you only need to do this in development, not in production.

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

Sidebar

Related Questions

I ask a similar question here and Darin Dimitrov answer that we can't use
I like to ask something that may be simple and stupid, but I can't
How can you setup an app that will ask for permission to access contacts
I am creating a script that I can run and it will simply ask
I just want to ask if there is any PHP/MySQL datatype that can store
I know there are posts that ask how one stores third-party libraries into source
I know there are several questions similar, but I can't find one that answers
Is there a way I can ask Visual source safe to get all the
I am using GAE with python and I can ask users to sign in
Can I ask the user WHERE to install the application during install time? Most

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.