如何实现从绝对路径上移一个文件夹?
文件结构:
/folder/
/folder/config.php
/folder/classes/test.php
我想在 test.php 中包含_once 或 require_once config.php 文件。
我已经在 test.php 中试过了,但它不起作用:
require_once(dirname(__FILE__) . '/../config.php');
错误信息: *PHP fatal error :require_once(): Failed opening required '/loooong-path/classes/../test.php'*
最佳答案
你可以试试:
require_once(realpath(__DIR__ . '/../config.php'));
未经测试,但理论上它应该有效。
关于php - 从绝对路径向上 move 文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15247084/