Is it good to store files outside public_html?

I recently created an Ajax Search Tutorial and the online demo showed database access login files. To prevent the public from viewing the login details they were saved in a file above the root. If the file existed the file was loaded and access details extracted otherwise about six Php constants had to be defined by the user when they downloaded the source files.

This [SOLVED] thread details how I could find the path above the root. from any folder beneath the root. This saved having to hard-code the above the root path every time the above the root folder was required.

Is there a simpler way to find the "AboveTheRoot" path?