Is it faster for PHP to read files or databases?
1. Directly reading files is more efficient than database query.
2. It can be inferred that the database efficiency will only get worse without testing when writing files and INSERT.
3. If a very small configuration file does not need to use database features, it is more suitable to be accessed in a separate file. There is no need to create a separate data table or record. Large files such as pictures, music, etc. use files. Storage is more convenient, and it is more reasonable to only put index information such as paths or thumbnails in the database.
4. If you only read files in PHP, file_get_contents is more efficient than fopen and fclose.
Recommended tutorial: PHP video tutorial
The above is the detailed content of Is it faster to read files in php or database?. For more information, please follow other related articles on the PHP Chinese website!