What is the difference between PHP require and include?

后端 未结 7 913
时光说笑
时光说笑 2020-11-30 12:35

I know the basic usage of PHP require, require once, include and include once. But I am confused about when I should use them.

Example: I have 3 files, eg: settings.

7条回答
  •  一整个雨季
    2020-11-30 13:08

    You don't load settings.php two times, as per PHP documentation on require_once;

    The require_once() statement is identical to require() except PHP will check if the file has already been included, and if so, not include (require) it again.

提交回复
热议问题