<p>I have seen a lot of <code>ob_get_clean()</code> the last while. Typically I have done <code>$test .= 'test'</code></p>

<p>I'm wondering if one is faster and/or better than the other.</p>

<p>Here is the code using <code>ob_get_clean()</code>:</p>

<pre><code>ob_start();

foreach($items as $item) {
    echo '&lt;div&gt;' . $item . '&lt;/div&gt;';
}

$test = ob_get_clean();
</code></pre>

<p>Here is the code using <code>$test .= 'test'</code>:</p>

<pre><code>$test = '';

foreach($items as $item) {
    $test .= '&lt;div&gt;' . $item . '&lt;/div&gt;';
}
</code></pre>

<p>Which is better?</p>

The results are the same, and I'd imagine the performance differences are negligible if any. Basically, a matter of personal style preference. I would go with concatenation myself - I use output buffering only when concatenation is not an option.
Also, instead of running both
```
ob_get_contents()
```
and
```
ob_clean()
```
simply run
```
ob_get_clean()
```
which performs both at once.