【问题标题】:php failed to load external entityphp 无法加载外部实体
【发布时间】:2015-01-28 19:06:37
【问题描述】:

这是我的代码,我正在使用 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> 

【问题讨论】:

    标签: php codeigniter xhtml


    【解决方案1】:

    我已经复制了您的代码,并且可以正常工作。但是我看到您的 index.php 在“views”文件夹中,并且您有一些 htaccess 文件,因此可能定义了一些重写并且它与工作目录混淆了一些东西。尝试使用绝对路径。如果它没有帮助并且您在 linux 上,请检查 note.xhtml 权限。

    <?php
    $xml=simplexml_load_file(__DIR__."/note.xhtml") or die("Error: Cannot create object");
    print_r($xml);
    ?> 
    

    【讨论】:

    • 它是正确的。我必须在我的文件之前添加“/”的确切答案:(."/note.xhtml")。
    【解决方案2】:

    您的网络服务器配置似乎有问题。 检查您的网络服务器是否允许从外部资源获取内容。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-19
      • 2013-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-11
      • 2018-09-22
      相关资源
      最近更新 更多