use output buffering, call the function ob_start and the beginning of your script.