In case someone is looking for how to do this in 2023 onwards, this is a quick note to say that all the ini_set() answers will only work in runtime from the time they are executed onwards.
This means that errors generated during file parse may still be sent to the browser, and of course those are probably the most common errors.
The usual fix for this varies widely depending on your version of PHP and how it is called; but it's always a variation of a file containing php settings; for instance, a php.ini. You could add this fragment to such a php.ini file:
display_errors = Off
log_errors = On
This would suppress browser errors while enabling logging to a file. You may also need to add the line error_log = error_log