如果希望使用require()将页眉和脚注加入到每个页面中,还有另外一种办法。在配置文件php.ini中有两个选项auto_prepend_file和auto_append_file。通过这两个选项来设置页眉和脚注,可以保证它们在每个页面的前后被载入。使用这些指令包含的文件可以像使用include()语句包含的文件一样;也就是,如果该文件不存在,将产生一个警告。
对于Windows,其设置如下所示:
auto_prepend_file = "c:/Program Files/include/header.php" auto_append_file = "c:/Program Files/include/footer.php"
对于UNIX,其设置如下所示:
auto_prepend_file = "/home/username/include/header.php" auto_append_file = "/home/username/include/footer.php"
如果使用了这些指令,就不需要再输入include()语句,但页眉和脚注在页面中不再是页面的可选内容。
如果使用的是Apache Web服务器,可以对单个目录进行不同配置选项的修改。这样做的前提是服务器允许重设其主配置文件。要给目录设定自动前加入和自动追加,需要在该目录中创建一个名为.htaccess的文件。这个文件需要包含如下两行代码:
php_value auto_prepend_file "/home/username/include/header.php" php_value auto_append_file "/home/username/include/footer.php"
请注意,其语法与配置文件php.ini中的相应选项有所不同,和行开始处的php_value一样:没有等号。许多php.ini中的配置设定也可以按这种方法进行修改。
在.htaccess中设置选项,而不是php.ini中 或是在Web服务器的配置文件中进行设置,将带来极大的灵活性。可以在一台只影响你的目录的共享机器上进行。不需要重新启动服务器而且不需要管理员权限。 使用.htaccess方法的一个缺点就是目录中每个被读取和被解析的文件每次都要进行处理,而不是只在启动时处理一次,所以性能会有所降低。
相关推荐
主要介绍了PHP中auto_prepend_file与auto_append_file用法,较为详细的讲述了配置信息的休息以及函数的用法和注意事项,需要的朋友可以参考下
5.2.3 使用auto_prepend_file和auto_append_file 5.3 在PHP中使用函数 5.3.1 调用函数 5.3.2 调用未定义的函数 5.3.3 理解字母大小写和函数名称 5.4 理解为什么要定义自己的函数 5.5 了解基本的函数结构 ...
5.2.3 使用auto_prepend_file和auto_append_file 5.3 在PHP中使用函数 5.3.1 调用函数 5.3.2 调用未定义的函数 5.3.3 理解字母大小写和函数名称 5.4 理解为什么要定义自己的函数 5.5 了解基本的函数结构 5.5.1 函数...
5.2.3 使用auto_prepend_file和auto_append_file 5.3 在PHP中使用函数 5.3.1 调用函数 5.3.2 调用未定义的函数 5.3.3 理解字母大小写和函数名称 5.4 理解为什么要定义自己的函数 5.5 了解基本的函数结构 ...
The syntax of the file is extremely simple. Whitespace and lines ; beginning with a semicolon are silently ignored (as you probably guessed). ; Section headers (e.g. [Foo]) are also silently ignored,...
使用$ import $ remove $ replace $ merge等操作来合并JSON(或YAML)文件和对象。 目录: 运作方式 $import $merge $remove $replace $concat $combine $append $prepend $insert $match $move $select...
jQuery中可以通过append在列表的最后添加数据,也可以通过prepend在列表的最前面添加数据 方法很简单: 代码如下: jQuery(‘#comment_list’).prepend(‘<li>hello www.jb51.net</li>’); 另外附上jquery实现连续...
hide() 和 show() 都可以设置两个可选参数:speed 和 callback。 语法: $(selector).hide(speed,callback) $(selector).show(speed,callback) speed 参数规定显示或隐藏的速度。可以设置这些值:"slow", "fast", ...
prepend(content|fn) prependTo(content) 外部插入 after(content|fn) before(content|fn) insertAfter(content) insertBefore(content) 包裹 wrap(html|ele|fn) unwrap() wrapall(html|ele) wrapInner...
append(content) appendTo(content) prepend(content) prependTo(content) 外部插入 after(content) before(content) insertAfter(content) insertBefore(content) 包裹 wrap(html) wrap(elem) wrapAll...
append(content) appendTo(content) prepend(content) prependTo(content) 外部插入 after(content) before(content) insertAfter(content) insertBefore(content) 包裹 wrap(html) wrap(elem) wrapAll...
image :reset :button :file :hidden 表单对象属性 :enabled :disabled :checked :selected 文档处理内部插入 append(content | fn) appendTo(content) prepend(content | fn) prependTo(content) 外部插入 after...
IE用户无法在线查看本文档,请下载jQuery API Version1.5 中文版AIR客户端查看,或者使用chrome,safari,firefox,opera等浏览器查看!!! jQuery 1.5 API Cheat Sheet来源 Selectors Basics #id element .class, ...
11.2 数组和对象操作 183 11.2.1 jQuery.each(object, [callback]) 183 11.2.2 jQuery.extend([deep], target, object1, [objectN]) 183 11.2.3 jQuery.grep(array, callback, [invert]) 185 11.2.4 jQuery.make...
append(content|fn) appendTo(content) prepend(content|fn) prependTo(content) 外部插入 after(content|fn) before(content|fn) insertAfter(content) insertBefore(content) 包裹 wrap(html|ele|fn) ...