Home > Backend Development > PHP Problem > What problems will you encounter in php development?

What problems will you encounter in php development?

藏色散人
Release: 2023-02-27 18:50:02
Original
2537 people have browsed it

What problems will you encounter in php development?

What problems will you encounter in php development?

Inventory of the top ten common PHP development problems

1. Use MyISAM instead of InnoDB

MyISAM is used by default. But unless you are building a very simple database or just doing it experimentally, most of the time this is the wrong choice. MyISAM does not support foreign key constraints, which is the essence of ensuring data integrity. In addition, MyISAM will lock the entire table when adding or updating data, which will cause big problems in future expansion performance.

2. Use PHP’s mysql method

PHP has provided the MySQL function library from the beginning. Many programs rely on mysql_connect, mysql_query, mysql_fetch_assoc, etc.

3. Not filtering user input

It should be: Never trust user input. Use back-end PHP to verify and filter each input information. Don't trust Javascript.

4. Do not use UTF-8

UTF-8 solves many internationalization problems. Although PHP6 can solve this problem more perfectly, it does not prevent you from setting the character set of MySQL to UTF-8.

5. Use PHP where SQL should be used

If you are new to MySQL, sometimes when solving problems, you may first consider using a language you are familiar with. This may cause some waste and poor performance. For example: when calculating the average, the MySQL native AVG() method is not used. Instead, PHP is used to loop through all the values ​​and then accumulate them to calculate the average.

What are the difficulties encountered in PHP development_Inventory of the top ten common problems in PHP development

6. Not optimizing the query

99% of PHP Performance problems are all caused by the database. A bad SQL statement may make your entire program very slow. MySQL's EXPLAIN statement, Query Profiler, and many other tools can help you find those naughty SELECTs.

7. Using the wrong data type

MySQL provides a series of data types such as numbers, strings, time, etc. If you want to store dates, use the DATE or DATETIME type. Using integers or strings makes things more complicated.

8. Use *

in the SELECT query. Do not use * to return all fields in the table, which will be very slow. You only need to take out the data fields you need. If you need to remove all fields, then maybe your table needs to be changed.

9. Under-indexing or over-indexing

Generally speaking, all fields that appear after WHERE in the SELECT statement should be indexed.

10. Not backing up

It may not happen often, but database damage, hard disk failure, service shutdown, etc., will cause catastrophic damage to the data. So you must make sure to automatically back up your data or save a copy.

For more PHP related knowledge, please visit PHP Chinese website!

The above is the detailed content of What problems will you encounter in php development?. For more information, please follow other related articles on the PHP Chinese website!

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