The best method I have found for protecting passwords stored in a php file is to protect the directory using .htaccess.
I create a folder called /include and I put all of the scripts that contain sensitive info in them there. For example I put all of my database connection scripts and ftp connection scripts that contain passwords in that folder. I don't put any file that I don't want to access through a php include statement in that directory though.
Then I create a .htaccess file as follows:
<Files ~ *>
Order allow,deny
Deny from all
Satisfy All
</Files>
This prevents any file in that directory from being executed or read from a web browser. The files can be included in another script though using PHP and will work fine. If PHP fails on your server, you don't run the risk of the passwords being exposed because the script that calls them through an include wouldn't function either.
If you want to only "hide" certain files in that directory replace the with the pattern to match. (i.e. .inc would hide any file ending in .inc).
Hope this helps.