代码之家  ›  专栏  ›  技术社区  ›  hamburger

如何将数组转换为fullphp之类的类

  •  0
  • hamburger  · 技术社区  · 8 年前

    我正在使用fullPHP库,我不了解一些源代码。

    Config::load('test.php', true);  
    

    测试。php如下所示:

    <?php
    
    return array(
      'base_url'  => null,
      'profiling_paths' => array(
          'APPPATH' => 'APPPATH',
          'COREPATH' => 'COREPATH',
          'PKGPATH' => 'PKGPATH'
      )
    );
    

    你可以在这里找到课程: https://github.com/fuel/core/blob/1.9/develop/classes/config.php

    1 回复  |  直到 8 年前
        1
  •  1
  •   tooleks    8 年前

    简而言之: Config::load('test.php', true) test.php 文件( array Config static::$items 属性数组。当你打电话的时候 Config::get('key') 从中获得的价值 按“键”的属性数组( static::$items['key']

    如果只想使用“面向对象风格”的数组,可以使用SPL库中的ArrayIterator类。

    $arrayObject = new ArrayIterator([]);
    

    请参阅 official documentation