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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:01:52+00:00 2026-05-13T23:01:52+00:00

I am wondering if there is any technique out there for making HTML code

  • 0

I am wondering if there is any technique out there for making HTML code look good when printing that HTML (multiple lines) from a PHP function?

In particular, new lines and tabs. Obviously, I want the HTML tags behind-the-scenes to look good with the proper new lines and tabs. However, depending on when I call the PHP function that is printing the HTML, I might need to start the tabs at 1, 2, 3, 4, etc. I don’t want to have to pass the starting tab count to the PHP function that is printing the HTML.

So, does anyone know a general-purpose way to print HTML-friendly code with PHP? Or is there a design principle that I am missing that says, “Don’t print multiple HTML lines from a PHP function.” …

Thanks,

Steve

  • 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-13T23:01:52+00:00Added an answer on May 13, 2026 at 11:01 pm

    Markup Cleanup

    There are some wonderful codetools out there that will cleanup (ie, adjust spacing) and repair (ie, close open tags).

    Tidy is one of the more popular html cleanup/repair tools. You can parse your script’s output through Tidy on-the-fly using php’s output buffers.

    Zend Dev Zone Intro – http://devzone.zend.com/article/761
    Tidy Docs in PHP Manual – http://www.php.net/manual/en/book.tidy.php

    And now, a trivial example, yay!

    <?php
    ob_start();
    
    echo '<div><b> messy</b> <div> <i>blarg</I></div>';
    echo '  <div>code rawr!</div>';
    
    $output = ob_get_clean();
    
    $tidy = tidy_parse_string($output);
    tidy_clean_repair($tidy);
    echo $tidy;
    ?>
    

    Templating System

    You should be using a templating system to separate the logic (php code) and presentation (html/markup/etc) parts of your application.

    Using this practice has many advantages including, among other things, making your code easier to maintain and debug.

    This is a huge topic of discussion, and almost always goes into frameworks and MVC. There are thousands of resources, here are a few 😛

    Writing a Template System in PHP – http://www.codewalkers.com/c/a/Display-Tutorials/Writing-a-Template-System-in-PHP/
    Separation of Business Logic from Presentation Logic in Web Applications – http://www.paragoncorporation.com/ArticleDetail.aspx?ArticleID=21

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

Sidebar

Related Questions

I am wondering if there are any techniques to identify a web crawler that
i just wondering is there any performance issue or anything thing wrong if that
I was wondering - are there any known techniques to control access to a
Just wondering is there any way I can check whether the url links to
Been wondering are there any ways to measure the learning performance of ANNs. Thanks
I am wondering is there any way we can test the font size/color of
I am wondering is there any way to execute following shell script, which waits
I am new to Rails, and i am wondering is there any concept like
I am working with Objective-C in Xcode. I was wondering is there any mechanism
I've been wrecking my brain trying to figure this out. is there any way

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.