包含和子包括(更正)

编程入门 行业动态 更新时间:2024-10-25 19:22:15
本文介绍了包含和子包括(更正)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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>写在 新闻:如果******************* @ news20.bellglobal: "Yannick Turgeon" <no****@nowhere> wrote in news:IF*******************@news20.bellglobal: 我们目前正在更改我们的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-

更多推荐

包含和子包括(更正)

本文发布于:2023-11-16 09:48:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1603180.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!