<?php function myDom($str) { // dom dom dom } ob_start("myDom"); echo '<div>Hello</div>'; ob_end_flush(); ?>