What's quicker; including another file or querying a MySQL database in PHP?

后端 未结 12 1715
闹比i
闹比i 2021-01-12 04:29

In PHP, which is quicker; using include(\'somefile.php\') or querying a MySQL database with a simple SELECT query to get the same information?

12条回答
  •  南笙
    南笙 (楼主)
    2021-01-12 05:15

    It depends. If your file is stored locally in your server and the database is installed in another machine, then the faster is to include the file.

    Buuuuut, because it depends on your system it could be not true. I suggest to you to make a PHP test script and run it 100 times from the command line, and repeat the test through HTTP (using cURL)

    Example:

    use_include.php

    
    

    use_myphp.php

    
    

提交回复
热议问题