require,include,require_once和include_once之间的区别? [英] Difference between require, include, require_once and include_once?

查看:198
本文介绍了require,include,require_once和include_once之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在PHP中:


  • 我应该何时使用 require vs. include

  • 我应该何时使用 require_once include_once

  • When should I use require vs. include?
  • When should I use require_once vs. include_once?

推荐答案

还要求 include_once

所以你的问题应该是...

So your question should be...


  1. 我应该何时使用 require include

  2. 我应该何时使用 require_once 要求

  1. When should I use require vs. include?
  2. When should I use require_once vs. require

1的答案描述为这里


require()函数与include()相同,除了它处理错误不同。如果发生错误,include()函数会生成警告,但脚本将继续执行。 require()生成致命错误,脚本将停止。

The require() function is identical to include(), except that it handles errors differently. If an error occurs, the include() function generates a warning, but the script will continue execution. The require() generates a fatal error, and the script will stop.

可以找到2的答案这里


require_once()语句与require()相同,除了PHP将检查文件是否已被包含,如果是,则不再包括(require)它。

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.

这篇关于require,include,require_once和include_once之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆