A
A
Andrey Makarov2016-05-10 16:24:28
PHP
Andrey Makarov, 2016-05-10 16:24:28

How to display a delayed view at the time of editing the buffer through callback ob_start?

I need to get the result of the output of the connected php file or any other function to the browser buffer while editing the buffer output to the browser

ob_start("onBufferFlush");

function onBufferFlush ($buffer) 
{
    ob_start();
    include("template.php");
    $content = ob_get_clean();
    return $content . $buffer;
}

"I built your ob-function inside the ob-function so that you can edit the buffer while editing the buffer"
Inside such a callback, functions of the ob family are no longer called. And in general, if you call at least 1 echo inside this callback, nothing will be displayed on the browser screen, neither a buffer, nor an error, nor a warning, just a white sheet. I do not want to generate dynamically html'ku on the fly into a string variable. Are there any solutions to this problem?
Smart people told me that you can't control a buffer with ob after it's been closed. Tell me then, please, how to display the delayed view? For example, there is a sidebar that is initialized in the header, and the content is typed into it along the page. How to template a view, if not with a php file, which contains html markup and small inserts of php code for dynamics? Do not collect the same string, really? It seems to me that there has been some solution for a long time, or I'm doing something wrong. Maybe some third-party templating like smarty is used?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question