I like to put them into an include file and encrypt that file using something like PHP accelerator or Zend Accelerator.
There's no absolutely foolproof answer.
As well as being protective of the connection details, which you obviously are - it's also important from the database server to lock down the mysql account to the minimum possible permissions. Only allow access to that user to the appropriate tables with the correct read/write level, and only from expected servers.