问题描述
我在一个网站上工作,并被要求包括位于我的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包含文件包括的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!