php include file that has includes

给你一囗甜甜゛ 提交于 2019-12-04 05:21:33

问题


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?


回答1:


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');




回答2:


Server side: include($_SERVER['DOCUMENT_ROOT'] . 'subfolder/file.php');

Means from the client side: {http://www.domain.com}/subfolder/file.php



来源:https://stackoverflow.com/questions/8920438/php-include-file-that-has-includes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!