Professional cms systems use a file they place in the root directory of the cms, if you take e.g. php-fusion there is a file named config.php where the database login information is stored within. Sorry, I can't tell you how files are read and written. I don't know .php.
Always learn from history, to be sure you make the same mistakes again...