php 解析yml

在 配置 項目時,遇到了 yml後綴的文件,好奇,本身寫個。解析看看。php

官網文章地址:http://php.net/manual/zh/book.yaml.php
composer

介紹了,pecl 安裝 yaml 來解析。感受不少時候環境所限,不能去編譯。ui

如今第二種方法   利用composer 安裝  composer require mustangostang/spyc 來解析spa


<?php  
require_once (PATH_ROOT. '/../../vendor/autoload.php');

$config_array = spyc_load_file('elastic.yml'); // 加載yaml 格式的文件  
// spyc_load_file(file_name);


function yaml_parse_file($file) {
        return Spyc::YAMLLoad($file);
}
相關文章
相關標籤/搜索