ob_start(); for($i = 0; $i < $num; $i++) { if (empty($postrow[$i]['id'])) {break;} $nomer = $postrow[$i]['id']; $raiting = $postrow[$i]['balls']; $date = $postrow[$i]['date']; $text = $postrow[$i]['text']; include "theme/post.php"; } $post = ob_get_contents(); ob_end_clean(); 

Is it possible to write such code without using a buffer?

    2 answers 2

    You can, if in theme/post.php do not echo "..." , but something like $html .= "..." and at the end of the file return $html . http://php.net/manual/en/function.include.php , Example # 5.

      To be honest, I don’t know, but in my opinion it’s impossible, you can only thrust the result of the file connection into a variable ( true / false ).