Chinaunix首页 | 论坛 | 博客
  • 博客访问: 259638
  • 博文数量: 30
  • 博客积分: 4450
  • 博客等级: 上校
  • 技术积分: 1085
  • 用 户 组: 普通用户
  • 注册时间: 2005-01-20 21:05
文章分类

全部博文(30)

文章存档

2011年(5)

2010年(5)

2008年(20)

我的朋友

分类: 系统运维

2011-03-17 21:39:33

用法:

include ("xxx.inc");

require ("xxx.inc");

include_once ("xxx.inc");

require_once ("xxx.inc");

区别和注意事项:

include 语句随时用到随时重新执行,require语句则是执行完一次之后,不再执行,仅应用结果。如果调用全局变量最好声明为全局变量 global 或者用 include,其实关键就是一个语法严谨性的问题。

include_once, require_once 用法同上。但是它们都会首先检查所要包含的文件是否已载入,如果已经载入了则不会重复载入,当然会影响到执行效率,不过是微乎其微的。

阅读(583) | 评论(1) | 转发(0) |
0

上一篇:没有了

下一篇:PHP中的正则式使用

给主人留下些什么吧!~~

kecai_cale2011-03-17 22:23:37

NOTE: This function changed how it worked.  In PHP 3 this behaved very differently than it does on PHP 4.  Require used to include and parse the file regardless where the require line was positioned.

For example (PHP3):

<?php
  if(false){ require_once 'file_does_not_exist.php'; }
?>

That code throw a fatal exception even though it's in a conditional block which evaluates to false.  In PHP 4 t