包含public_html之外的文件 [英] include file outside from public_html

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

问题描述

我想在php中包含public_html之外的文件.

Ι want to include a file outside from public_html in php.

我在public_html外部放置了一个文件,并试图将该文件包含到public_html/myDirectory存在的文件中.

I placed a file outside from public_html and tried to include this file, to a file that exists to public_html/myDirectory.

我尝试了这个include '../../myFile.php';,但是它不起作用.

I tried this include '../../myFile.php'; but it's not working.

我在哪里错了?

感谢您的帮助.

推荐答案

/是绝对系统路径 使用您的目录名称

/ is absolute system path to get your directory name use

echo $_SERVER['DOCUMENT_ROOT'];

文件位置第一个文件夹仅用于/

where your file position the first folder use / only

include '/myfile.php';

第二个目录使用文件名

 include '/filename/myfile.php';

否则,请使用curl或file get

other wise use curl or file get

file_get_contents("/myfile.php"); //http://yoururl.com/myfile.php

更新您的主要代码,包括备用

update your main code include alternate

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

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