header('Content-Type: application/json;charset=utf-8');
2: When accepting data submitted by the form, be sure to determine whether it is What was submitted?
if($_SERVER['REQUEST_METHOD']=='POST'){}
3: Do not copy duplicate codes, maintenance is too complicated
4: Never do it when querying data Directly use variables to input
Use placeholder operations in PDO as much as possible. Another way is to use escape to filter special strings
5: Do not directly appear numbers (magic num) in the written data. Do not play with this kind of magic numbers. It is best to define this number as a constant in front of the method and call it with self::constant name
The above introduces some details to pay attention to when writing PHP code (novice), including aspects of content. I hope it will be helpful to friends who are interested in PHP tutorials.