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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:46:53+00:00 2026-05-25T20:46:53+00:00

Question Updated I am building an MVC framework, for my templates and views, I

  • 0

Question Updated

I am building an MVC framework, for my templates and views, I will have a main page template file and my views will be included into this template.

The only way I have seen to do this is to use output buffereing

ob_start();
include 'userProfile.php';
$content = ob_get_clean();

Is there any other way of doing this? I think output buffering is not the best on performance as it uses a lot of memory

Here is a sample controller, the $this->view->load('userProfile', $profileData);
is the part that will be loaded using output biffering so that it can be included into the main template below into the $content part

view class

public function load($view,$data = null) {

    if($data) {
        $this->data = $data;
        extract($data);
    } elseif($this->data != null) {
            extract($this->data);
    }

    ob_start();
    require(APP_PATH . "Views/$view.php");
    $content = ob_get_clean();
}

controller

/**
 * Example Controller
 */
class User_Controller extends Core_Controller {



    // domain.com/user/id-53463463
    function profile($userId)
    {
        // load a Model
        $this->loadModel('profile');  
        //GET data from a Model
        $profileData = $this->profile_model->getProfile($userId);

        // load view file
        $this->view->load('userProfile', $profileData);
    }
}

main site template

<html>
<head>

</head>

<body>

<?php echo $content; ?>

</body>
</html>
  • 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-25T20:46:53+00:00Added an answer on May 25, 2026 at 8:46 pm

    Using a template system is not necessarily tied to output buffering. There are a couple of things in the example code you give that should certainly not be taken for granted:

    One:

    flushblocks(); // what does this do??
    

    And two:

    $s = ob_get_clean();
    

    Why does the code capture the template output into a variable? Is it necessary to do some processing on this before outputting it? If not, you could simply lose the output buffering calls and let the output be sent to the browser immediately.

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

Sidebar

Related Questions

I have a self-rolled MVC framework that I am building, and up to this
UPDATED: Added one more question (Question #4). Hi all, I'm building myself a custom
I'm building an ASP.NET MVC site where I want one of the Views I
I am building an Asp.net MVC site where I have a fast dedicated server
I have recently been learning Python and am dipping my hand into building a
I have a basic question regarding populating Core Data with data. I am building
I have a question about the Qibla direction, I am building an iPhone application
Question Updated for Bounty In Flash I need to load a dynamically generated XML
UPDATED QUESTION Since the ctor is not supported by .NETCF (public FileStream(IntPtr handle, FileAccess
Updated question, see below I'm starting a new project and I would like to

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.