What is the best way to keep your MySQL credentials private in PHP?

前端 未结 4 553
孤独总比滥情好
孤独总比滥情好 2021-01-25 18:37

When it comes to programming your web application in php, what is the most efficient way to prevent your MySQL information from being disclosed or discovered by another person (

4条回答
  •  闹比i
    闹比i (楼主)
    2021-01-25 19:00

    I cannot say if this is the best, but this is how I do it;

    I have a config.php file, which holds my DB connection credentials, and is not directly accessible. I have a DB class which requires the config.php to make the connection, and I have a site class which extends the DB class.

    This is a very common way of doing things, and is generally accepted.

提交回复
热议问题