The best/most secure way to do this is to use an include file and place it outside of your web root. If you have the following directories and files...
/home/www/
/home/www/index.php
/home/includes/
/home/includes/database.inc
use include("../includes/database.inc") in index.php to include your database information. This is secure because it's outside of your web root, so no one can access it. You also keep all of your database information centralized and only include the file when you need it.
---John Holmes...