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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:46:11+00:00 2026-05-22T22:46:11+00:00

I am working on a website with 2 other developers. I am only responsible

  • 0

I am working on a website with 2 other developers. I am only responsible to creating the views.

The data is available in an object, and I have getters to read the data then create XHTML pages.

What is the best practice to do this, without using any template engine?

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-22T22:46:12+00:00Added an answer on May 22, 2026 at 10:46 pm

    If you don’t want to use a templating engine, you can make use of PHP’s basic templating capabilities.

    Actually, you should just write the HTML, and whenever you need to output a variable’s value, open a PHP part with <?php and close it with ?>. I will assume for the examples that $data is your data object.

    For example:

    <div id="fos"><?php echo $data->getWhatever(); ?></div>
    

    Please note that, all PHP control structures (like if, foreach, while, etc.) also have a syntax that can be used for templating. You can look these up in their PHP manual pages.

    For example:

    <div id="fos2">
    <?php if ($data->getAnother() > 0) : ?>
        <span>X</span>
    <?php else : ?>
        <span>Y</span>
    <?php endif; ?>
    </div>
    

    If you know that short tag usage will be enabled on the server, for simplicity you can use them as well (not advised in XML and XHTML). With short tags, you can simply open your PHP part with <? and close it with ?>. Also, <?=$var?> is a shorthand for echoing something.

    First example with short tags:

    <div id="fos"><?=$data->getWhatever()?></div>
    

    You should be aware of where you use line breaks and spaces though. The browser will receive the same text you write (except the PHP parts). What I mean by this:

    Writing this code:

    <?php
        echo '<img src="x.jpg" alt="" />';
        echo '<img src="y.jpg" alt="" />';
    ?>
    

    is not equivalent to this one:

    <img src="x.jpg" alt="" />
    <img src="y.jpg" alt="" />
    

    Because in the second one you have an actual \n between the img elements, which will be translated by the browser as a space character and displayed as an actual space between the images if they are inline.

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

Sidebar

Related Questions

I am working on a web site with several other developers and we have
I am working on a website (Asp.net mvc), where I have multiple partial views.
We are a team of many developers working on a website that uses both
I have a working website on a pre-production server, all functions are responding correctly.
I'm working on a website that will switch to a new style on a
We are working on a website for a client that (for once) is expected
I'm working on a website that uses lots of png24 files, for transparency. I
I am working on my website, and I am trying to get the url
I'm working on a website that uses not just frames, but frames within frames
I'm working on a website with a em-based layout (so it can stretch and

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.