Rather than making code modifications, I would recommend setting the php setting display_errors to off. This will prevent any messages from being written out to the page. It is recommended to hide error messages on a live production server like you said.
If you have access to the php.ini, you can change the setting there. Otherwise this line of php should also work:
ini_set('display_errors', 'off');
-justin