dousheyan0375 2018-07-23 15:44
浏览 114

在PHP的SimpleXMLElement中,如何传递多个libXml选项? [重复]

This question already has an answer here:

The answer to this is probably studpidly simple, but I can't for the life of me figure it out...

Per PHP's documentation, the 2nd parameter for the "SimpleXMLElement::__construct()" method, called "$option", is an integer, defined as: "Optionally used to specify additional Libxml parameters." Please note the plural of "parameters".

I get how to pass a single option, say:

$x = new SimpleXMLElement($feed_url, LIBXML_NOCDATA, TRUE);

But what if, in addition to "LIBXML_NOCDATA", I want to also pass "LIBXML_NOBLANKS", and/or "LIBXML_BIGLINES"? How do I pass those within the same call?

Example:

$x = new SimpleXMLElement($feed_url, LIBXML_NOCDATA LIBXML_NOBLANKS LIBXML_BIGLINES, TRUE);

(BTW, I know this doesn't work...)

What am I missing / not understanding?

Thanks!

</div>
  • 写回答

1条回答 默认 最新

  • douzhaiyuan1731 2018-07-23 15:47
    关注

    Use a bitwise OR to get the final value.

    $x = new SimpleXMLElement($feed_url, LIBXML_NOCDATA | LIBXML_NOBLANKS | LIBXML_BIGLINES, TRUE);
    
    评论

报告相同问题?

悬赏问题

  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?