php中require跟include的几点区别

WBOY
Release: 2016-06-13 10:40:12
Original
758 people have browsed it

php中require和include的几点区别

  • 如果php.ini配置文件配置了URL fopen wrappers, 那么require可以使用URL包含远程文件的调用
  • require中不能包含控制结构, 而且不能包含return语句, 会产生处理错误.
  • require会在第一次执行的时候, 将被包含文件的内容替换至此, 而include每次调用都会重新调用.所以require不可以在循环体重包含不同的文件.
  • require可以访问当前作用域中的变量
  • require发生错误会立即停止运行, 报出异常, 而include显示错误信息后, 继续执行.
  • 在条件语句中的require, 不管该条件是否成立, 被包含的内容都会被引入, 哪怕没有执行的机会.

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!