我有一个问题,PHP包含路径,它在两个环境中表现不同。
文件夹结构:
窗
|-C:\wamp\www\cms\themes\child
|-C:\wamp\www\cms\themes\parent
的Linux
|-/var/www/html/cms/themes/child
|-/var/www/html/cms/themes/parent
Linux Environtment
var_dump(realpath('/')); // means /
var_dump(realpath('/../parent/scripts/import.php')); //boolean false
include('/../parent/scripts/import.php'); //it will not work
include('../parent/scripts/import.php'); //it will not work, except it will reference parent folder
Windows环境
var_dump(realpath('/')); //C:\
var_dump(realpath('/../parent/scripts/import.php')); //boolean false
include('../parent/scripts/import.php'); //am thinking it will work at first, but it does not work in windows (feel weird)
include('/../parent/scripts/import.php'); //it work in windows (feel weird)
我知道最佳做法是,它适用于两个平台
include(realpath(dirname(__FILE__)).'/../parent/scripts/import.php');
但我想知道这个,它是一个PHP错误或是什么导致这个?
答案 0 :(得分:-1)
不是它不是窗口文件系统和linux文件系统之间差异的错误