+9  A: 

You can use Output Buffering as

ob_start();
echo "MESSI is injured!!";
header("Location:somepage.php");
ob_end_flush();

The problem is that we cannot send the header after we start sending the output. To solve this we buffer the output. The function ob_start turns output buffering on. While output buffering is active no output is sent from the script (other than headers), instead the output is stored in an internal buffer. So the echo output will be buffered. Next we send the header without any problem as we've not yet spit out any output. Finally we call ob_end_flush to flush the internal buffer contents and to stop output buffering.

codaddict
Absolutely right
tilman
Actually if you have output buffering on, *nothing* will be sent before you flush it. Not even headers. (iirc)
Jani Hartikainen
+2  A: 

You can do it as long as all the header calls come before any non-header output is sent (this includes pesky things like newlines/whitespace). So

<?php
header("Location:somepage.php");
echo "MESSI is injured!!";
?>

should do the trick

gmarcotte
Dosen't quite answer the question: write echo “” **and then** header()
codaddict
Exactly. Output buffering should solve the problem, though.
matsolof