php无法加载外部实体
这是我的代码,我正在使用CI,我收到错误I/O警告:无法加载外部实体“note.xhtml” index.phpphp无法加载外部实体,php,codeigniter,xhtml,Php,Codeigniter,Xhtml,这是我的代码,我正在使用CI,我收到错误I/O警告:无法加载外部实体“note.xhtml” index.php <?php $xml=simplexml_load_file("note.xhtml") or die("Error: Cannot create object"); print_r($xml); ?> note.xhtml <?xml version="1.0" encoding="UTF-8"?> <note>
<?php
$xml=simplexml_load_file("note.xhtml") or die("Error: Cannot create object");
print_r($xml);
?>
note.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
托弗
贾尼
提醒
这个周末别忘了我!
我复制了您的代码,它可以正常工作。但是我看到您的index.php位于“views”文件夹中,并且您有一些htaccess文件,因此可能定义了一些重写,这会使工作目录出错。尝试使用绝对路径。如果没有帮助,并且您在linux上,请检查note.xhtml权限
<?php
$xml=simplexml_load_file(__DIR__."/note.xhtml") or die("Error: Cannot create object");
print_r($xml);
?>
您的web服务器配置似乎有问题。
检查您的web服务器是否允许从外部资源获取内容。这是正确的。我必须在文件之前添加“/”(.“/note.xhtml”)的确切答案。