To add to other answers:
If you use a file extension such as .inc, then there is a higher risk. Can you open the file directly in your browser?
The most important tip is missing:
Only the files that the browser should access should be in a public place. All other code (and configuration) must be in a completely separate directory.
for instance
root - webroot - includes - config
The web server (apache) is only available "webroot". Webroot can contain, for example, one index.php along with all your assets (javascript, css, images).
Any index.php code that needs to be downloaded comes from 'includes' and the entire configuration from 'config'. There is no way that a user can ever directly access any of these 2 directories, if done correctly.
Evert source share