Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php无法加载外部实体_Php_Codeigniter_Xhtml - Fatal编程技术网

php无法加载外部实体

php无法加载外部实体,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>

这是我的代码,我正在使用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>
      <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”)的确切答案。