4

I usually code like this:

$output .= 'custom code';
    $output .= 'another line of custom code';
$output .= 'more code';     

return $output;

Now I want to use ob_start(), ob_get_contents() and ob_get_clean(). What's the most effective way to use it inside my example?

1 Answer 1

10

This will return the same as your example given :

ob_start();
echo 'custom code';
echo 'another line of custom code';
echo 'more code';
return ob_get_clean();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.