【问题标题】:ZF2: Define empty array in XML configuration fileZF2:在 XML 配置文件中定义空数组
【发布时间】:2013-11-27 02:46:56
【问题描述】:

我已通过关注this example 将我的应用程序设置为使用模块配置 xml。

现在我需要为一个配置键定义一个空数组。等效的 php 配置文件是:

<?php
return array (
  //...the other configurations
  'sample' => array(
    'empty' => array()
  )
);

我不知道如何在 xml 中构建它。 如果我尝试以下 xml,解析器会返回一个空字符串,但我需要一个空数组。

<?xml version="1.0" encoding="UTF-8"?>
<zend-config>
    <!-- ...the other configurations -->
    <sample>
        <empty></empty>
    </sample>
</zend-config>

是否有一个选项可以强制 Zend\Config\Factory 返回一个数组而不是一个字符串?

【问题讨论】:

    标签: php zend-framework2 app-config configuration-files


    【解决方案1】:

    你是说这个吗?

    <zend-config>
        <sample>
            <empty/>
        </sample>
    </zend-config>
    

    【讨论】:

    • 谢谢!这就是解决方案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-14
    • 1970-01-01
    • 2015-01-14
    • 2018-06-28
    • 1970-01-01
    相关资源
    最近更新 更多