Nothing is safe if you don’t know what you’re doing. Almost all the sites on the Internet today are insecure because almost all of them are made by people who think they can decorate cake recipes and this is enough to make a website.
Interestingly in desktop systems that do not involve internet security can usually be neglected without major problems. But those people who do not know what they are doing prefer to do for the web, not even knowing that the best solution is probably for desktop or mobile. Web should be the last option when others are not suitable. That is, it is a sum of errors.
It is not enough to answer this question to maintain security. And everyone thinks that just this one and a half dozen more and it is all right. Security is a mobile target, it always changes, so you can only make it safe if you understand a lot of computing.
To answer this question, yes, it is safe if everything is done right. Doing it wrong isn’t. Doing it right involves a lot of things, but the main thing is to configure the server properly to process PHP pages always and not expose them. But don’t think this is enough.
If all is right any request for something with extension .php
will be delivered to the PHP interpreter that will execute the code on the server and will send a response to the HTTP server that will send to the browser. So unless you do something absurdly wrong, almost impossible, none of the PHP code will go to the HTTP server and consequently to the client. The PHP code is usually mixed HTML with PHP, only the part of HTML and what the programming code generates in the request will go to the browser.
The fact that it does not go to the browser does not mean that it is safe, only that it will not go there under normal conditions.
And don’t trust random people on the internet. There are some myths in the answers posted here, but most are right.
Adopting a framework would no longer be a measure to increase security?
– gato
I don’t know, a lot of them cause insecurity, and if you use them wrong, it might be easier to cause insecurity. They help not to commit the fools, but it makes it easier to commit the hairy ones. The more complexity, the more abstraction, the more each adds, the easier it is to make a mistake and not notice. Of course, between doing everything wrong because you have no idea what you’re doing and a framework, the second is better, but it is still not a good solution, the solution is to learn everything right, dedicate yourself, or hire someone who knows how to do.
– Maniero