php包含文件包括 [英] php include file that has includes

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

问题描述

我在一个网站上工作,并被要求包括位于我的php脚本上方的文件夹中的文件.问题是我被要求包括的那些php文件,其中包含了.因此,在调用我的php页面时找不到它们引用的文件.

处理这种情况的最佳方法是什么?

解决方案

当将文件从文件夹B包含到文件夹A时,B脚本的行为就像它存储在A中一样.要么更改指针路径,要么更改chdir()./p>

http://se2.php.net/manual/en/function. chdir.php

或者使用完整路径而不是本地路径.如

$ home ='/home/user/path/to/root/;

Include_once($ home .'folderb/script.php');

I am working on a site and have been asked to include files that are sitting in a folder above my php scripts. Problem is those php files I have been asked to include, have includes in them. And thus the files they refer to cannot be found when calling my php pages.

What is the best way to handle this situation?

解决方案

When including a file from folder B to folder A, the B script acts like it was stored in A. Either change your pointer paths or chdir().

http://se2.php.net/manual/en/function.chdir.php

Or use full paths rather than local. Such as

$home = '/home/user/path/to/root/;

Include_once($home .'folderb/script.php');

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

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