Some details to pay attention to when writing PHP code (rookie)

WBOY
Release: 2016-08-08 09:27:23
Original
1294 people have browsed it
1: Remember to add header information when using json_encode to output data

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!