“Parse Error: syntax error, unexpected $end” is one of those less-than-transparent error messages. What exactly does it mean?
Usually this error is trying to tell you that a curly brace was opened but never closed: an opening if (condition) { with no closing }; or, as another example, an foreach($var as $subVar): with no endforeach;.