包含和子包括(更正) [英] Include and sub-includes (correction)

查看:72
本文介绍了包含和子包括(更正)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Oups!我在上一篇文章中输入了错误。固定。

-----------


大家好,


我们是目前正在更改我们的Web服务器,并在此过程中将PHP

版本从4.3.0更新为4.3.5。我们遇到的问题是我们的方式来支付b
包括其他文件中的一些文件已经不再正常工作了。我们收到的消息看起来像:PHP警告:主要(.. \db.inc.php):无法打开

stream:没有这样的文件或...目录...


假设我们有这个文件结构:


myApplication(dir)

index.php

include(dir)

db.inc.php

authentification(dir)

用户.inc.php

login.php

- user.inc.php包含db.inc.php调用" include(''.. \ db.inc。 php'')"

- login.php和index.php都包含user.inc.php

- index.php调用" include(''include \\ \\ authentification\user.inc.ph p'')"

- login.php calls" include(''user.inc.php'')" < - 在这里更正


我知道我可以解决这个问题,让那些包括绝对的

而不是亲戚,但我宁愿让它相对对于一些

发展的原因。 myApplication实际上包含许多其他文件

调用" include(''.. \ db.inc.php'')"所以我不想移动这个文件。


我们的旧配置似乎包括在他们的父母中包含孩子

,然后包括父母包括在主文件中。现在似乎

在包括孩子之前包括父母。


任何人都知道为什么它不再工作以及我能做些什么来解决这个问题?


Yannick


Oups! I did a typing error in my last post. Fixed.
-----------

Hello all,

We are currently changing our web server and, in the process, updating PHP
version from 4.3.0 to 4.3.5. The problem we''ve got is that our way to
include some files in other ones is no more working properly. The message we
are getting looks like: "PHP Warning: main(..\db.inc.php): failed to open
stream: No such file or directory in ..."

Say we have this file structure:

myApplication (dir)
index.php
include (dir)
db.inc.php
authentification (dir)
user.inc.php
login.php
- user.inc.php includes db.inc.php calling "include(''..\db.inc.php'')"
- both login.php and index.php includes user.inc.php
- index.php calls "include(''include\authentification\user.inc.ph p'')"
- login.php calls "include(''user.inc.php'')" <-- Corrected here

I know I could solve this problem by making those the includes absolute
instead of relative but I would prefer to let it relative for some
developement reason. myApplication actually contains many other files
calling "include(''..\db.inc.php'')" so I don''t want to move this file.

Our old configuration seems to include child-includes in their parents
before including the parent-include in the main file. Now it seems to
include parent before include childs.

Any one has an idea why it''s no more working and what I could do solve this?

Yannick


推荐答案

" Yannick Turgeon" <无**** @ nowhere.com>写在

新闻:如果******************* @ news20.bellglobal.com:
"Yannick Turgeon" <no****@nowhere.com> wrote in
news:IF*******************@news20.bellglobal.com:
我们目前正在更改我们的Web服务器,并在此过程中将PHP版本从4.3.0更新为4.3.5。我们遇到的问题是我们的方式将一些文件包含在其他文件中是不行的。我们得到的消息如下:PHP警告:主要(.. \db.inc.php):
无法打开流:在...中没有这样的文件或目录
We are currently changing our web server and, in the process, updating
PHP version from 4.3.0 to 4.3.5. The problem we''ve got is that our way
to include some files in other ones is no more working properly. The
message we are getting looks like: "PHP Warning: main(..\db.inc.php):
failed to open stream: No such file or directory in ..."




" {



"{


_SERVER [''DOCUMENT_ROOT'']} / db.inc.php"取代../ db.inc.php应该

做奇迹;现在你的包含不再需要关心它们在

文件系统中的位置。
_SERVER[''DOCUMENT_ROOT'']}/db.inc.php" in place of "../db.inc.php" should
do wonders; now your includes no longer have to care where in the
filesystem they are.


Hello Eric,感谢回复。


此解决方案的问题是:

1-我的开发环境位于同一个

服务器上的不同目录中。这样,当我将新版本发送到生产时,我将不得不更改包含文件的每个引用



2 -
Hello Eric, thanks to reply.

The problem with this solution is:
1- My developement environment is in a different directory on the same
server. That way, I would have to change every reference to included files
when I send new version to production.
2-


这篇关于包含和子包括(更正)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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