doumei3828 2012-06-01 13:53
浏览 105
已采纳

在PHP中存储敏感数据

I'm working on a PHP project and I'm using a global settings file which I include where I need some global values such as database credentials for connecting to mysql. For example:

settings.php:

<?php          
    const DB_ADDRESS = 'localhost';
    const DB_USERNAME = 'johndoe';
    const DB_PASSWORD = 'mypassword';
    const DB_PORT = 7777;   
?>

My question, is it safe enough? For example, is there any way to see variables values while debugging in explorer/chrome? Is there any alternative safer way?

Thanks.

  • 写回答

6条回答 默认 最新

  • dshdsh2016 2012-06-01 13:55
    关注

    PHP information is processed on the server before being sent to the browser so it can't be seen inside of a browser under normal circumstances. However, if your webserver is misconfigured the plain text version of your code may be sent to the browser thus rendering it visible to users. That's why important code should always be kept outside of your document root and included into files when needed.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?