php - 在 .ini 文件中使用相对路径
问题描述
我在我的网站https://www.example.com的根目录中创建了一个 .user.ini,只有一行:
auto_prepend_file = "/path/to/my/website/includes/prepend.php"
它工作正常。
我现在在 https:// development .example.com 设置开发环境 我将所有文件从生产站点复制到开发站点。
有没有办法重写我的 .user.ini 以使用相对路径?像这样的东西:
auto_prepend_file = doc_root + "/includes/prepend.php"
或者可能
auto_prepend_file = "includes/prepend.php"
这样我就不必在每次进行生产或开发工作时都更新 .user.ini 文件。
谢谢。
解决方案
只需将相对路径保留在 ini 文件中,稍后在 php 逻辑中的“自动前置”过程中添加 doc-root。
您可以通过 index.php 在 index.php 中获取文档根目录
define('DOCUMENT_ROOT', __DIR__);
并在您喜欢的脚本中随处使用它。
推荐阅读
- macos - 定期运行远程备份
- pine-script - 策略订单 - 无法对某些资产使用小数订单数量(FTX 上的 SOLUSD)
- dropzone - Dropzone uploadprogress 进度在大文件加载前立即 100
- python - 如何让 Snakemake 在确定哪些输入文件已更改时忽略更新的文件?
- python - 迭代元组中的元素(Python)
- node.js - Node js使用代理重定向来自客户端的请求
- django - Django 仅查询属于该公司的员工
- gpu - 为 DMA 查找 NVIDIA GPU 内存的物理地址
- javascript - 如何让动画运行以及同时更改 innerHTML 属性?
- react-native - UI Kitten - RangeCalendar 组件不适合手机屏幕宽度。如何处理组件的宽度?