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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:30:56+00:00 2026-05-28T15:30:56+00:00

I read somewhere that you should separate you web pages into 3 tiers: Fetch,

  • 0

I read somewhere that you should separate you web pages into 3 tiers: Fetch, Logic, Presentation.

  • Fetch: Grab information from database/session etc
  • Logic: Calculate what you need
  • Presentation: Display the HTML

So first off, is this a good idea? I can see some clear benefits (organization, easy modification). Secondly, seeing as with this model echoing out HTML is no good, should I store the HTML I want in variables?

Example:

<?php

/** fetch **/
include("session_validator.php");

$secret = $_GET['secret'];

mysql_connect($host, $user, $pass);
// connect and query
$username = mysql_result($result, 0, 'username');

/** logic **/
if (isset($secret)) {
    $message = "You know the secret!";
} else {
    $message = "The secret is wrong";
}

/** presentation **/
?>
<html>
<body>
    Username: <?php echo $username; ?> <br>
    Secret? <?php echo $message; ?>
</body>
</html>

To reiterate my question, is storing my information in $message and closing off the PHP section before presentation a good idea? Or am I misunderstanding the whole tiered concept?

  • 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-28T15:30:57+00:00Added an answer on May 28, 2026 at 3:30 pm

    This design is often referred to as MVC (Model View Controller), and it is a bit different than what you described:

    • Controller – The part receiving the requests and handles them. It calls both Models and Views.
    • Model – The logic part, this is where the heavy PHP coding will take effect. This is the part where you fetch information from databases/files, do calculations, and then return the data back to the Controller.
    • View – The presentational part of your app, generally it will mostly contain HTML (and/or other client-side languages) and it is the page presented to the client. The Controller passes the data from the Model to it, and then it can be parsed (Views generally allow PHP code inside of them) and presented.

    I think it’s a good pattern because it allows for clear separation and easy maintenance. It also allows you to separate the work between the front-end and back-end (specifically if you have different developers for each side!).

    As for the echoing part, the only place where you would echo HTML is in your View, so there’s no problem there.

    I suggest you take a look at a well documented framework (such as codeigniter) and start reading.

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

Sidebar

Related Questions

I read somewhere that - You should put all CSS (files) into one single
I read somewhere that one should never use error conditions as normal program flow.
I read somewhere that I should stop using <%= … %> to render and
I read somewhere that functions should always return only one type so the following
When I was learning PHP, I read somewhere that you should always use the
I read somewhere that I should be performing validation in my BLL as well
I've read somewhere that one should use a for loop when you are iterating
I've read somewhere that one should use a for loop when you are iterating
i read somewhere that ob_start() should be places top of the page. whereas somewhere
I read somewhere that when creating a HTML email, you should use the table-based

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.