cbassett03 Posted December 4, 2009 Share Posted December 4, 2009 Is there a way to protect PHP source code from being viewed? I was playing with HTML and PHP, and from what I can see, if you simiply link to a PHP file (without any parameters) and if someone right-clicks on the link and says "Download Target" or "Save Link As" from a browser, they can sometimes download the PHP file with source and all. How can I either prevent this from being done or protect the source code of my PHP files? I'm not so concerned about PHP files with SQL queries in them, but more about PHP files with information regarding accessing a database (username, password, host information, etc). Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted December 4, 2009 Share Posted December 4, 2009 When you download a page via "save link as" you get the raw HTML that was created from the PHP, not the PHP source itself. If people could just download the page and get the PHP, people could just steal the code of sites like Facebook Quote Link to comment Share on other sites More sharing options...
oni-kun Posted December 4, 2009 Share Posted December 4, 2009 "save as" is the equivalent to viewing the page, except saving it for later. The server cannot divulge the PHP code unless there is a security issue in your code or server which you misconfigured. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.