Best Practices for creating a PHP INI/CONFIG file and keep it secure

﹥>﹥吖頭↗ 提交于 2019-12-03 08:13:48

It is quite safe and I don't think there is any best practice for constants, but I tend to gather them in a dedicated Constants class for readability:

class Constants {
    const DB_PASS = 'mypass';
}

Naming your PHP file something that begins with .ht (for instance .htconfig.inc.php) also helps, since Apache usually has a rule never to serve any files that are named .ht*. But placing your file outside of the document root is even better.

unless someone has access to your PHP source code that is secure.

however I would make sure the file is outside of the document root to prevent problems IF for some reason php gets turned off on the website and all of a sudden people can see the source of your files :).

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!