Passwords are best stored away from third-parties, and although PHP code should not be readable it is not unheard of to have a server misconfiguration leak PHP code in plaintext.
By storing the configurations (including the password) in an external file, this file can be put outside of the publicly accessible server directory.