Php 无法使用simplexml\u load\u文件访问目录
因此,我不确定我的代码为什么不能工作,但下面是我得到的错误:Php 无法使用simplexml\u load\u文件访问目录,php,simplexml,Php,Simplexml,因此,我不确定我的代码为什么不能工作,但下面是我得到的错误: Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "../../setting.xml" in /home1/sk8ermid/public_html/MVP/themes/SDS-2013/home.php on line 3 以下是我使用的代码: <?php
Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "../../setting.xml" in /home1/sk8ermid/public_html/MVP/themes/SDS-2013/home.php on line 3
以下是我使用的代码:
<?php
$settings = simplexml_load_file('../../setting.xml');
$site_title = $settings->title;
?>
我正试图进入“settings.xml”文件所在的两个目录。我这样做是正确的还是有其他的方法呢?试试这个
$settings = simplexml_load_file(__DIR__ . '/../../setting.xml');
请始终记住
(CWD)是PHP脚本目录,位于任何include
/require
树的根目录,并且只有在您配置的include\u path
实际包含
(默认情况下是这样的,但这可以在代码中更改)
如果您的home.php
脚本被另一个脚本包含在另一个目录中,
与另一个脚本相对
使用\uuuu DIR\uuuu
确保始终从当前脚本的父目录开始
看