【问题标题】:Simplepie includes phantom enclosures that don't existSimplepie 包括不存在的幻像外壳
【发布时间】:2010-10-29 16:02:53
【问题描述】:

我正在组合两个带有附件的提要,没有附件的项目显示为空附件。

下面是粗体字的代码:

<item>
<title><?echo $item->get_title(); ?></title>
<guid><? echo $item->get_permalink(); ?></guid>
<link><? echo $item->get_permalink(); ?></link>
**<? if ($enclosure = $item->get_enclosure()) {echo "<enclosure url='"
.$enclosure->get_link() ."' length='" .$enclosure->get_length() ."' type='"
.$enclosure->get_type() ."' />";} ?>**
<description>
<? echo $item->get_title(); ?>
</description>
</item>

没有附件的项目显示为空的附件 url、长度和类型:

所有真实的附件都显示为应有的 url、长度和类型。我在 Simplepie 支持页面上阅读了一些主题,但没有找到解决方案。

谢谢!

【问题讨论】:

  • 如果没有外壳,$item-&gt;get_enclosure() 会返回什么?

标签: php simplepie


【解决方案1】:

我不了解 Simplepie,但查看代码,$item-&gt;get_enclosure() 可能返回一个计算结果为 true 的对象,但它是空的。所以也许你应该将if 的条件更改为:

<? $enclosure = $item->get_enclosure(); if ($enclosure->get_link()) {...

【讨论】:

    猜你喜欢
    • 2020-02-28
    • 2014-06-12
    • 2017-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-14
    相关资源
    最近更新 更多