You can use the PHP md5 encryption libraries to encrypt the password, and then save it in a text file. Since md5 is not reversible, the password will be secure.
You definitely do not want to store in plain text.
You can also save the password in a PHP file, but using an encrypted hash. The advantage of the file is that the data is separated from the business logic, which makes it easy to add a database or the ability to use multiple users / passwords.
UPDATE If you store the password in plain text in a PHP script unencrypted, anyone who breaks into your server or has access to the server can read the contents of your PHP files in plain text.
source share