PHP Security-data submitted by users many major vulnerabilities in PHP programs are not caused by the PHP language itself, but by the low security awareness of programmers. Therefore, you must always pay attention to the possible problems in each piece of code to find out the possible impact of incorrect data submission.
Example #1 dangerous variable usage
Always pay attention to your code to ensure that all the variables submitted from the client are properly checked and then ask yourself the following questions:
Can this script only affect the expected files?
Can an abnormal data be used after it is submitted?
Can this script be used for unplanned purposes?
Can this script be combined with other scripts to do bad things?
Are all transactions fully recorded?
Ask yourself these questions when writing code. Otherwise, you may need to rewrite the code to increase security. If you pay attention to these problems, you may not be able to guarantee the security of the system, but at least you can improve the security.
You can also consider disabling register_globals, magic_quotes, or other settings that make programming more convenient but make the legitimacy of a variable, and the sources and values of the variable messy. During development, you can use the error_reporting (E_ALL) mode to check whether the variables have been checked or initialized before they are used, so as to prevent some abnormal data from being scratched.