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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:03:28+00:00 2026-05-13T07:03:28+00:00

I have this idea: when someone calls mysite.com/layer1/layer2/something , then I want to start

  • 0

I have this idea:

when someone calls mysite.com/layer1/layer2/something, then I want to start the action called something. That action is simply a file in an actions directory which contains a function. This function takes some context parameters and is supposed to return HTML output. This output, which goes into a variable, will then be brought into an main template, and finally the little framework will throw out the whole html output at once.

Now I don’t know if it’s good or bad design to return big amounts of html code from a function or method?

  • 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-13T07:03:28+00:00Added an answer on May 13, 2026 at 7:03 am

    There’s nothing wrong with returning HTML from a function provided that function lives in the presentation layer and you maintain good seperation of business/controller/presentation logic.

    However, in this particular case, I’d recommend having your “action” files just dump their output via echo, and capturing it with output buffering wherever you’re doing your original function call. This way, your action files don’t have to worry about concatting a bunch of data onto a buffer variable and making sure it gets returned. Also, because these files are (presumably) largely HTML oriented, you’ll be able to use the much nicer and more legiable syntax:

    <div id="Outer">
      <?= $content ?>
      <p class="Inner">
        <?= $more_content ?>
      </p>
    </div>
    

    As opposed to:

    $buffer .= '<div id="Outer">' . $content .
               '<p class="Inner">' . $more_content .
               '</p></div>';
    

    At the very least, the first way allows your IDE/editor to perform proper syntax highlighting.

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

Sidebar

Related Questions

I have this idea where I want to allow someone to call a phone
I have no idea why this is throwing an error - hoping someone can
everyone, i have no idea why this doesn't work hopefully someone here can help
I have this idea for a free backup application. The largest problem I need
I have this grand idea to basically employ some brute force attack to test/verify
What is the purpose of annotations in Java? I have this fuzzy idea of
I have a html like this: The idea is that divs are floated left
I have no idea why this is happening. I have some very straightforward code,
I have no idea if this is possible, but if it is, what would
I have no idea why this doesn't work, but doing some validation functions 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.