Yes, you can. Try it.
Actually, your Thank you isn't even within the PHP code because you stop PHP before it and then restart PHP after.
You could also have written it like this (I'm not suggesting one way is better than another):
<?php
//success html below
echo "<h2 class='myclass'>Thank you for contacting us. We will be in touch with you very soon. Use your back button to return to our website.</h2>";
}
die();
?>