php - 在 public_html 之外包含文件
问题描述
我想在 php 中包含 public_html 之外的文件。
我在 public_html 之外放置了一个文件,并尝试将此文件包含到 public_html/myDirectory 中存在的文件中。
我试过这个include '../../myFile.php';
,但它不工作。
我哪里错了?
谢谢你的帮助。
解决方案
/
是获取目录名称的绝对系统路径
echo $_SERVER['DOCUMENT_ROOT'];
您的文件位置第一个文件夹/
仅使用
include '/myfile.php';
第二个目录使用文件名
include '/filename/myfile.php';
其他明智的使用 curl 或文件获取
file_get_contents("/myfile.php"); //http://yoururl.com/myfile.php
更新您的主要代码包括备用
推荐阅读
- python - 尝试在 Lambda 函数中运行 ansible - 无法使依赖项达到可接受的上传大小
- javascript - Javascript:在 Reduce 函数中无法理解空初始化器
- r - 循环遍历数据表列并使用 for 循环应用 glm
- mongodb - 更好的方法创建 estructure 集合 mongodb,更新并插入子文档
- ios - 数据在 CollectionView 单元格中未正确显示?
- c# - Foreach 循环遍历字典导致 StackOverflowException
- python-3.x - 形状力图不显示图:shap.plots._force.AdditiveForceVisualizer
- javafx - 如何在 JavaFX 中绘制等边三角形?
- uipath - UiPath 助理和开发人员认证徽章显示在简历中
- r - 按组有效地重复观察