Oh dear... you need to learn PHP... copy and paste won't cut it :)
You've left in the ?> tag, ending the code before the function is complete, let alone the class. I assume that's what $end is referring to. You should remove the second <?php declaration as well.