You usually deal with this with environment variables. It can be a configuration file .php (or .ini, .yml, .xml, whatever you use for config files) that you load on startup, and has environment-specific values. For example, in your production server, your environment config file might look like this:
$config['environment'] = 'production';
Another option is to use environment variables provided by your web server. Both approaches are fine, though I prefer the former.
Then you catch ALL uncaught exceptions (and also turn errors into exceptions. Having errors disabled can be annoying during development, and having errors enabled and not catching them can be a huge security hole in production) with an 'universal error catcher' (I haven't tried this one, but looks good. In the past I used one I wrote myself, but it was very tricky, I don't recommend writing your own catcher, other than for learning purposes). Then just do something like this:
if($config['environment'] == 'production') {
echo 'Oops, something went wrong';
} else {
// print full backtrace and stuff
}
As a sidenote, this is the kind of problem a 'framework' is supposed to solve for you. If you use Silex or Symfony 2, this functionality is available by default.