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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:05:47+00:00 2026-05-23T17:05:47+00:00

I have a php function that generates HTML code like below function j_uf_SomeFunction($some_var) {

  • 0

I have a php function that generates HTML code like below

function j_uf_SomeFunction($some_var) {
    ?><div class="db_photo">
        <img alt="<?php echo some_php_function ?>" src="<?php echo $some_var; ?>" />
    </div><?php
}

Of course, its much more advanced and add all sorts of user options.

In most case I place this function inline, as opposed to have to append it to a string. However, I’ve come to the first occurrence (probably not the last occurrence) where I need to store the rendered HTML in a string and not have it sent straight off to the parser for building the page.

I need to cut the function off and tell it to take the html generated and store it in a string, and not send it off to the page, only on certain situations.

  • 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-23T17:05:47+00:00Added an answer on May 23, 2026 at 5:05 pm
    function j_uf_SomeFunction($some_var) {
        ob_start();
        ?><div class="db_photo">
            <img alt="<?php echo some_php_function ?>" src="<?php echo $some_var; ?>" />
        </div><?php
      return ob_get_clean();//suggestion by GWW
    }
    

    ob_start() is starting buffer receive
    ob_get_clean() cleans current buffer and returns its value.

    More info on http://php.net/manual/en/function.ob-start.php

    ob * output buffering

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

Sidebar

Related Questions

I have some jQuery code. I have called an Ajax function file, file.php, that
I have code with the following form: <?php function doSomething{ //Do stuff with MySQL
i need help with disk_total_space function.. i have this on my code <?php $sql=select
I seem to be confused about PHP output buffering. I have code like this:
Is there any way to have PHP automatically call a function, before a script
I have a JavaScript function, pop_item . I have to call this from PHP,
I have this little function function makewindows(){ child1 = window.open (about:blank); child1.document.write(<?php echo htmlspecialchars(json_encode($row2['ARTICLE_DESC']),
I have PHP configured so that magic quotes are on and register globals are
We have PHP 5.2.6 deployed to c:\php and in that folder there is the
I have seen many PHP function on how to generate a <ul><li> tag but

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.