Output buffering on shared server

I noticed my output buffering wasn’t working on my shared Dreamhost server. I have a very simple PHP script to test it:

<?php ob_start(); echo 'should be buffered
'; $buffered = ''; while(ob_get_level() > 1) { $buffered .= ob_get_clean(); } echo 'yep
'.$buffered; ?>

This doesn’t work properly. Or an even simpler example:

<?php ob_start(); echo (ob_get_level() > 1) ? 'buffering on':'buffering off'; ?>

Does anyone know what I need to do? Is output buffering possible on a shared server?

ob_get_level() starts at the value 0. After the ob_start() it becomes 1. So it actually works as expected.

On other hosts the ob_get_level() might be 1 at the start, if output buffering is on by default.

Thanks for the reply! You’re right, it was just a silly mistake.