<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: 深入理解PHP之require/include顺序</title>
	<atom:link href="http://www.laruence.com/2010/05/04/1450.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.laruence.com/2010/05/04/1450.html</link>
	<description>PHP语言, PHP扩展, Zend引擎相关的研究,技术,新闻分享 - 左手代码 右手诗</description>
	<lastBuildDate>Thu, 09 Feb 2012 12:31:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
	<item>
		<title>By: Berc</title>
		<link>http://www.laruence.com/2010/05/04/1450.html/comment-page-1#comment-5070</link>
		<dc:creator>Berc</dc:creator>
		<pubDate>Mon, 10 Oct 2011 04:23:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.laruence.com/2010/05/04/1450.html#comment-5070</guid>
		<description>我最近遇到一个很奇怪的问题
例如 1.php 中 include &#039;common/2.php&#039;;
1.php和目录处于同一级目录。
如上写，在我测试的两台电脑都可以用，这应该是由于include_path=&#039;.;c:\php52&#039; 的作用。
但是我这样写 include &#039;./common/2.php&#039;;就无法找到文件2.php了（两台电脑，一台可以，另外一台就不行）
根据手册说的如果以. 或..开头，会直接在当前目录开始查找，为什么其中一台电脑就不行了呢？

希望鸟哥看一看这个奇怪的问题。
如果可以的话，能否发到我邮箱 308840239#qq.com
再次先谢过了</description>
		<content:encoded><![CDATA[<p>我最近遇到一个很奇怪的问题<br />
例如 1.php 中 include &#8216;common/2.php&#8217;;<br />
1.php和目录处于同一级目录。<br />
如上写，在我测试的两台电脑都可以用，这应该是由于include_path=&#8217;.;c:\php52&#8242; 的作用。<br />
但是我这样写 include &#8216;./common/2.php&#8217;;就无法找到文件2.php了（两台电脑，一台可以，另外一台就不行）<br />
根据手册说的如果以. 或..开头，会直接在当前目录开始查找，为什么其中一台电脑就不行了呢？</p>
<p>希望鸟哥看一看这个奇怪的问题。<br />
如果可以的话，能否发到我邮箱 308840239#qq.com<br />
再次先谢过了</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: php require和include的区别 &#124; web开发</title>
		<link>http://www.laruence.com/2010/05/04/1450.html/comment-page-1#comment-4567</link>
		<dc:creator>php require和include的区别 &#124; web开发</dc:creator>
		<pubDate>Tue, 05 Jul 2011 03:14:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.laruence.com/2010/05/04/1450.html#comment-4567</guid>
		<description>[...] 见到鸟哥的一文：深入理解PHP之require/include顺序 http://www.laruence.com/2010/05/04/1450.html [...]</description>
		<content:encoded><![CDATA[<p>[...] 见到鸟哥的一文：深入理解PHP之require/include顺序 <a href="http://www.laruence.com/2010/05/04/1450.html" rel="nofollow">http://www.laruence.com/2010/05/04/1450.html</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 从php核心代码看require和include的区别 &#124; 炮灰`Blog</title>
		<link>http://www.laruence.com/2010/05/04/1450.html/comment-page-1#comment-4545</link>
		<dc:creator>从php核心代码看require和include的区别 &#124; 炮灰`Blog</dc:creator>
		<pubDate>Sat, 02 Jul 2011 15:25:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.laruence.com/2010/05/04/1450.html#comment-4545</guid>
		<description>[...] 见到鸟哥的一文：深入理解PHP之require/include顺序 http://www.laruence.com/2010/05/04/1450.html 忍不住继续再深入了一下下，在此记录一下深入的过程，以供以后查阅。 [...]</description>
		<content:encoded><![CDATA[<p>[...] 见到鸟哥的一文：深入理解PHP之require/include顺序 <a href="http://www.laruence.com/2010/05/04/1450.html" rel="nofollow">http://www.laruence.com/2010/05/04/1450.html</a> 忍不住继续再深入了一下下，在此记录一下深入的过程，以供以后查阅。 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 深入理解PHP之require/include顺序 &#124; 万维网黑客联盟</title>
		<link>http://www.laruence.com/2010/05/04/1450.html/comment-page-1#comment-3958</link>
		<dc:creator>深入理解PHP之require/include顺序 &#124; 万维网黑客联盟</dc:creator>
		<pubDate>Sun, 20 Mar 2011 12:57:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.laruence.com/2010/05/04/1450.html#comment-3958</guid>
		<description>[...] 本文地址: http://www.laruence.com/2010/05/04/1450.html [...]</description>
		<content:encoded><![CDATA[<p>[...] 本文地址: <a href="http://www.laruence.com/2010/05/04/1450.html" rel="nofollow">http://www.laruence.com/2010/05/04/1450.html</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 雪候鸟</title>
		<link>http://www.laruence.com/2010/05/04/1450.html/comment-page-1#comment-3814</link>
		<dc:creator>雪候鸟</dc:creator>
		<pubDate>Wed, 09 Mar 2011 08:20:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.laruence.com/2010/05/04/1450.html#comment-3814</guid>
		<description>@liujin834 你是想做什么呢? 应用场景, 还是只是说对这段代码本身的改进?</description>
		<content:encoded><![CDATA[<p>@liujin834 你是想做什么呢? 应用场景, 还是只是说对这段代码本身的改进?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: liujin834</title>
		<link>http://www.laruence.com/2010/05/04/1450.html/comment-page-1#comment-3809</link>
		<dc:creator>liujin834</dc:creator>
		<pubDate>Wed, 09 Mar 2011 05:41:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.laruence.com/2010/05/04/1450.html#comment-3809</guid>
		<description>您好！我想请教一个问题，我现在的代码是这样写的

if ($_SERVER[&quot;DOCUMENT_ROOT&quot;]) {
    $Root = $_SERVER[&quot;DOCUMENT_ROOT&quot;];
    $Root = rtrim($Root,&quot;/\\&quot;);
}
else {
    $Root = str_replace(DIRECTORY_SEPARATOR . &quot;include&quot;, &quot;&quot;, dirname(__FILE__));
}
define(&quot;ROOT&quot;, $Root);
$includePaths = array(
    ROOT . &quot;/libs&quot;,
    get_include_path()
);
set_include_path(implode(PATH_SEPARATOR, $includePaths));

怎么改进才能使效率更高一些？</description>
		<content:encoded><![CDATA[<p>您好！我想请教一个问题，我现在的代码是这样写的</p>
<p>if ($_SERVER["DOCUMENT_ROOT"]) {<br />
    $Root = $_SERVER["DOCUMENT_ROOT"];<br />
    $Root = rtrim($Root,&#8221;/\\&#8221;);<br />
}<br />
else {<br />
    $Root = str_replace(DIRECTORY_SEPARATOR . &#8220;include&#8221;, &#8220;&#8221;, dirname(__FILE__));<br />
}<br />
define(&#8220;ROOT&#8221;, $Root);<br />
$includePaths = array(<br />
    ROOT . &#8220;/libs&#8221;,<br />
    get_include_path()<br />
);<br />
set_include_path(implode(PATH_SEPARATOR, $includePaths));</p>
<p>怎么改进才能使效率更高一些？</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 小兴</title>
		<link>http://www.laruence.com/2010/05/04/1450.html/comment-page-1#comment-3716</link>
		<dc:creator>小兴</dc:creator>
		<pubDate>Wed, 16 Feb 2011 09:17:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.laruence.com/2010/05/04/1450.html#comment-3716</guid>
		<description>我做了个简单的测试，有两个页面a.php和b.php，并且a.php中require了b.php, 代码如下：

a.php

test();

require ‘b.php’;

function test()
{
echo ‘a.php test’;
}
===========================================
b.php

function test()
{
//重复定义函数
}

程序运行结果是：

a.php test

并且抛出一个函数重复定义的致命错误，我的疑问是：

1. a.php页面在b.php页面抛出了一个致命错误的前提下为什么还能正确输出本页面的test函数结果？

2. 包含页面和被包含页面之间的编译、执行顺序的原理是怎么样的？

非常希望能得到你的解惑，谢谢！</description>
		<content:encoded><![CDATA[<p>我做了个简单的测试，有两个页面a.php和b.php，并且a.php中require了b.php, 代码如下：</p>
<p>a.php</p>
<p>test();</p>
<p>require ‘b.php’;</p>
<p>function test()<br />
{<br />
echo ‘a.php test’;<br />
}<br />
===========================================<br />
b.php</p>
<p>function test()<br />
{<br />
//重复定义函数<br />
}</p>
<p>程序运行结果是：</p>
<p>a.php test</p>
<p>并且抛出一个函数重复定义的致命错误，我的疑问是：</p>
<p>1. a.php页面在b.php页面抛出了一个致命错误的前提下为什么还能正确输出本页面的test函数结果？</p>
<p>2. 包含页面和被包含页面之间的编译、执行顺序的原理是怎么样的？</p>
<p>非常希望能得到你的解惑，谢谢！</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 小兴</title>
		<link>http://www.laruence.com/2010/05/04/1450.html/comment-page-1#comment-3693</link>
		<dc:creator>小兴</dc:creator>
		<pubDate>Wed, 09 Feb 2011 02:17:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.laruence.com/2010/05/04/1450.html#comment-3693</guid>
		<description>非常抱歉，第三点是我遗漏了代码，在增加了top函数后，a.php页面还是可以正常运行test和top函数的，假设应该是成立的

“3. 从运行的结果来看，本页的函数test应该是在执行包含文件操作之前已经被预处理过了，但是我在a.php和b.php页面中都增加了一个函数top，代码如下：

function top()
{
echo ‘top’;
}

这个时候a.php页面还是只能运行test函数的结果，不管top函数是在b.php页面中test函数定义之前还是之后，a.php都无法运行top函数，这和之前的假设又矛盾了，很困惑”</description>
		<content:encoded><![CDATA[<p>非常抱歉，第三点是我遗漏了代码，在增加了top函数后，a.php页面还是可以正常运行test和top函数的，假设应该是成立的</p>
<p>“3. 从运行的结果来看，本页的函数test应该是在执行包含文件操作之前已经被预处理过了，但是我在a.php和b.php页面中都增加了一个函数top，代码如下：</p>
<p>function top()<br />
{<br />
echo ‘top’;<br />
}</p>
<p>这个时候a.php页面还是只能运行test函数的结果，不管top函数是在b.php页面中test函数定义之前还是之后，a.php都无法运行top函数，这和之前的假设又矛盾了，很困惑”</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 小兴</title>
		<link>http://www.laruence.com/2010/05/04/1450.html/comment-page-1#comment-3692</link>
		<dc:creator>小兴</dc:creator>
		<pubDate>Wed, 09 Feb 2011 02:13:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.laruence.com/2010/05/04/1450.html#comment-3692</guid>
		<description>我做了个简单的测试，有两个页面a.php和b.php，并且a.php中require了b.php, 代码如下：

a.php

test();

require  &#039;b.php&#039;;

function test()
{
    echo &#039;a.php test&#039;;
}
===========================================
b.php

function test()
{
    //重复定义函数
}

程序运行结果是：

a.php test

并且抛出一个函数重复定义的致命错误，我的疑问是：

1. a.php页面在b.php页面抛出了一个致命错误的前提下为什么还能正确输出本页面的test函数结果？

2. 包含页面和被包含页面之间的编译、执行顺序的原理是怎么样的？

3. 从运行的结果来看，本页的函数test应该是在执行包含文件操作之前已经被预处理过了，但是我在a.php和b.php页面中都增加了一个函数top，代码如下：

function top()
{
    echo &#039;top&#039;;
}

这个时候a.php页面还是只能运行test函数的结果，不管top函数是在b.php页面中test函数定义之前还是之后，a.php都无法运行top函数，这和之前的假设又矛盾了，很困惑，非常希望能得到你的解惑，谢谢！</description>
		<content:encoded><![CDATA[<p>我做了个简单的测试，有两个页面a.php和b.php，并且a.php中require了b.php, 代码如下：</p>
<p>a.php</p>
<p>test();</p>
<p>require  &#8216;b.php&#8217;;</p>
<p>function test()<br />
{<br />
    echo &#8216;a.php test&#8217;;<br />
}<br />
===========================================<br />
b.php</p>
<p>function test()<br />
{<br />
    //重复定义函数<br />
}</p>
<p>程序运行结果是：</p>
<p>a.php test</p>
<p>并且抛出一个函数重复定义的致命错误，我的疑问是：</p>
<p>1. a.php页面在b.php页面抛出了一个致命错误的前提下为什么还能正确输出本页面的test函数结果？</p>
<p>2. 包含页面和被包含页面之间的编译、执行顺序的原理是怎么样的？</p>
<p>3. 从运行的结果来看，本页的函数test应该是在执行包含文件操作之前已经被预处理过了，但是我在a.php和b.php页面中都增加了一个函数top，代码如下：</p>
<p>function top()<br />
{<br />
    echo &#8216;top&#8217;;<br />
}</p>
<p>这个时候a.php页面还是只能运行test函数的结果，不管top函数是在b.php页面中test函数定义之前还是之后，a.php都无法运行top函数，这和之前的假设又矛盾了，很困惑，非常希望能得到你的解惑，谢谢！</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 雪候鸟</title>
		<link>http://www.laruence.com/2010/05/04/1450.html/comment-page-1#comment-3690</link>
		<dc:creator>雪候鸟</dc:creator>
		<pubDate>Tue, 08 Feb 2011 15:41:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.laruence.com/2010/05/04/1450.html#comment-3690</guid>
		<description>@小兴 include/require都是语句， 是在执行时刻才把被包含的文件纳入进来，编译执行。</description>
		<content:encoded><![CDATA[<p>@小兴 include/require都是语句， 是在执行时刻才把被包含的文件纳入进来，编译执行。</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 小兴</title>
		<link>http://www.laruence.com/2010/05/04/1450.html/comment-page-1#comment-3689</link>
		<dc:creator>小兴</dc:creator>
		<pubDate>Tue, 08 Feb 2011 07:29:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.laruence.com/2010/05/04/1450.html#comment-3689</guid>
		<description>您好，请教一个问题，以前在网上看到过一种说法，说 include其实就是将要被包含的文件全部读入包含文件中，在这个过程中并不解析这些被包含的文件，而是将它们组成了一个大文件后再统一进行解析，我自己测试时发现并不完全是这样，请教您怎样理解include、require和PHP解析流程之间的关系呢，多谢！</description>
		<content:encoded><![CDATA[<p>您好，请教一个问题，以前在网上看到过一种说法，说 include其实就是将要被包含的文件全部读入包含文件中，在这个过程中并不解析这些被包含的文件，而是将它们组成了一个大文件后再统一进行解析，我自己测试时发现并不完全是这样，请教您怎样理解include、require和PHP解析流程之间的关系呢，多谢！</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: heihusdm</title>
		<link>http://www.laruence.com/2010/05/04/1450.html/comment-page-1#comment-3271</link>
		<dc:creator>heihusdm</dc:creator>
		<pubDate>Sun, 26 Sep 2010 10:23:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.laruence.com/2010/05/04/1450.html#comment-3271</guid>
		<description>学习了，收益匪浅啊</description>
		<content:encoded><![CDATA[<p>学习了，收益匪浅啊</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 深入理解 PHP之require/include顺序 &#124; haohtml&#39;s blog</title>
		<link>http://www.laruence.com/2010/05/04/1450.html/comment-page-1#comment-2885</link>
		<dc:creator>深入理解 PHP之require/include顺序 &#124; haohtml&#39;s blog</dc:creator>
		<pubDate>Mon, 05 Jul 2010 10:07:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.laruence.com/2010/05/04/1450.html#comment-2885</guid>
		<description>[...] 本文地址: http://www.laruence.com/2010/05/04/1450.html [...]</description>
		<content:encoded><![CDATA[<p>[...] 本文地址: <a href="http://www.laruence.com/2010/05/04/1450.html" rel="nofollow">http://www.laruence.com/2010/05/04/1450.html</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 从php核心代码看require和include的区别 &#124; haohtml&#39;s blog</title>
		<link>http://www.laruence.com/2010/05/04/1450.html/comment-page-1#comment-2874</link>
		<dc:creator>从php核心代码看require和include的区别 &#124; haohtml&#39;s blog</dc:creator>
		<pubDate>Fri, 02 Jul 2010 11:01:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.laruence.com/2010/05/04/1450.html#comment-2874</guid>
		<description>[...] 见到鸟哥的一文：深入理解PHP之require/include顺序 http://www.laruence.com/2010/05/04/1450.html [...]</description>
		<content:encoded><![CDATA[<p>[...] 见到鸟哥的一文：深入理解PHP之require/include顺序 <a href="http://www.laruence.com/2010/05/04/1450.html" rel="nofollow">http://www.laruence.com/2010/05/04/1450.html</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: av</title>
		<link>http://www.laruence.com/2010/05/04/1450.html/comment-page-1#comment-2733</link>
		<dc:creator>av</dc:creator>
		<pubDate>Thu, 10 Jun 2010 05:19:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.laruence.com/2010/05/04/1450.html#comment-2733</guid>
		<description>一直学习中。。...</description>
		<content:encoded><![CDATA[<p>一直学习中。。&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 深入理解PHP之require/include顺序-传播、沟通、分享-一直“有你”</title>
		<link>http://www.laruence.com/2010/05/04/1450.html/comment-page-1#comment-2554</link>
		<dc:creator>深入理解PHP之require/include顺序-传播、沟通、分享-一直“有你”</dc:creator>
		<pubDate>Wed, 05 May 2010 16:32:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.laruence.com/2010/05/04/1450.html#comment-2554</guid>
		<description>[...] 本文地址: http://www.laruence.com/2010/05/04/1450.html [...]</description>
		<content:encoded><![CDATA[<p>[...] 本文地址: <a href="http://www.laruence.com/2010/05/04/1450.html" rel="nofollow">http://www.laruence.com/2010/05/04/1450.html</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: yufeng</title>
		<link>http://www.laruence.com/2010/05/04/1450.html/comment-page-1#comment-2553</link>
		<dc:creator>yufeng</dc:creator>
		<pubDate>Wed, 05 May 2010 11:02:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.laruence.com/2010/05/04/1450.html#comment-2553</guid>
		<description>学习……这个问题本质上是个寻找文件优先级的问题吧，
基本上的顺序是：

1.绝对路径
2.遍历include_path中的路径
3.相对于current_script_dir的相对路径

而且，有两点总结：
  1.只要找到了，就不再向下寻找了。
  2.如果找不到，就一定会向下寻找。即使使用绝对路径，当文件不存在时，PHP依然会按这个次序进入include_path和current_script_dir的相对路径中寻找（当然更找不到了）。</description>
		<content:encoded><![CDATA[<p>学习……这个问题本质上是个寻找文件优先级的问题吧，<br />
基本上的顺序是：</p>
<p>1.绝对路径<br />
2.遍历include_path中的路径<br />
3.相对于current_script_dir的相对路径</p>
<p>而且，有两点总结：<br />
  1.只要找到了，就不再向下寻找了。<br />
  2.如果找不到，就一定会向下寻找。即使使用绝对路径，当文件不存在时，PHP依然会按这个次序进入include_path和current_script_dir的相对路径中寻找（当然更找不到了）。</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 从php核心代码看require和include的区别 - 五四陈科学院-php和java第一院</title>
		<link>http://www.laruence.com/2010/05/04/1450.html/comment-page-1#comment-2552</link>
		<dc:creator>从php核心代码看require和include的区别 - 五四陈科学院-php和java第一院</dc:creator>
		<pubDate>Wed, 05 May 2010 10:23:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.laruence.com/2010/05/04/1450.html#comment-2552</guid>
		<description>[...] 见到鸟哥的一文：深入理解PHP之require/include顺序 http://www.laruence.com/2010/05/04/1450.html [...]</description>
		<content:encoded><![CDATA[<p>[...] 见到鸟哥的一文：深入理解PHP之require/include顺序 <a href="http://www.laruence.com/2010/05/04/1450.html" rel="nofollow">http://www.laruence.com/2010/05/04/1450.html</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 雪候鸟</title>
		<link>http://www.laruence.com/2010/05/04/1450.html/comment-page-1#comment-2549</link>
		<dc:creator>雪候鸟</dc:creator>
		<pubDate>Wed, 05 May 2010 05:53:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.laruence.com/2010/05/04/1450.html#comment-2549</guid>
		<description>@N 哦,对, 我设计的例子有问题, 其实是为了说明current_script_dir, 谢谢指正.</description>
		<content:encoded><![CDATA[<p>@N 哦,对, 我设计的例子有问题, 其实是为了说明current_script_dir, 谢谢指正.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dd</title>
		<link>http://www.laruence.com/2010/05/04/1450.html/comment-page-1#comment-2548</link>
		<dc:creator>dd</dc:creator>
		<pubDate>Wed, 05 May 2010 05:39:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.laruence.com/2010/05/04/1450.html#comment-2548</guid>
		<description>主要是在include嵌套的时候，都是以最开始执行的php文件所在的路径为cwd，这样就都理解了。</description>
		<content:encoded><![CDATA[<p>主要是在include嵌套的时候，都是以最开始执行的php文件所在的路径为cwd，这样就都理解了。</p>
]]></content:encoded>
	</item>
</channel>
</rss>

