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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:49:22+00:00 2026-05-14T05:49:22+00:00

How can we separate Logic from presentation without using any template engine (traditional php-not

  • 0

How can we separate Logic from presentation without using any template engine (traditional php-not OOP)
Thank in advance

  • 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-14T05:49:23+00:00Added an answer on May 14, 2026 at 5:49 am

    Why not to use PHP itself as a template engine? It being used in the code I posted for your other question. Your program has to be split into 2 main sections: getting data and displaying data.

    Each page have to have it’s own template. In the code I posted there is 2 very simple templates, form.php and list.php
    just extend it with the whole site template, And you have done!
    Here is a little more complex PHP template example:

    <table border="0" cellpadding="2" cellspacing="0" width="600">
    <? foreach ($data as $row): ?> 
      <tr bgcolor="#666699">
        <td align=left>
          <font color="white"><b><?=$row['name']?></b></font>
        </td>
        <td align=right><font color="white">
          <?=$row['date'] ?>
        </font></td>
      </tr>
      <tr bgcolor="f0f0f0">
        <td colspan=2><?=$row['body'] ?></td>
      </tr>
      <? if ($row['answer']): ?>
      <tr bgcolor="d3d3d3">
        <td colspan=2 valign="top">
          <table border="0" cellpadding="0" cellspacing="5">
            <tr>
              <td valign="top"><b>Answer: </b></td>
              <td><?=$row['answer'] ?></td>
            </tr>
          </table>
        </td>
      </tr>
      <? endif ?>
      <? if($admin): ?>
      <tr>
        <td colspan=2>
          <font size=-1>
          <?=$row['id']?> - <?=$row['ip']?> - <?=$row['topic']?>
      <? if($row['del']): ?>
          <a href="/gb/?action=show&id=<?=$row['id']?>">show</a>
      <? else: ?>
          <a href="/gb/?action=hide&id=<?=$row['id']?>">hide</a>
      <? endif ?>
          <a href="/gb/?action=edit&id=<?=$row['id']?>">edit</a>
          </font>
        </td>
      </tr>
      <? endif ?>
    <? endforeach ?>
    </table>
    

    And it is called like this

    <?
    //some code to get data
    include 'tpl_top.php';
    include 'tpl_list.php';
    include 'tpl_bottom.php';
    ?>
    

    Looks magnificent to me!
    Dunno though, if it’s what you’re asking for 🙂

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

Sidebar

Ask A Question

Stats

  • Questions 405k
  • Answers 405k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Looks like a limitation of the underlaying platform ( Windows… May 15, 2026 at 5:55 am
  • Editorial Team
    Editorial Team added an answer This can be accomplished using recursive queries and CTEs ;WITH… May 15, 2026 at 5:55 am
  • Editorial Team
    Editorial Team added an answer Commented out this whole thing and the error went away… May 15, 2026 at 5:55 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.