Home  >  Article  >  Backend Development  >  php 解析yml

php 解析yml

WBOY
WBOYOriginal
2016-06-20 12:29:172454browse

在 配置 项目时,遇到了 yml后缀的文件,好奇,自己写个。解析看看。

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

介绍了,pecl 安装 yaml 来解析。感觉很多时候环境所限,不能去编译。

现在第二种方法   利用composer 安装  composer require mustangostang/spyc 来解析


<?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);}




Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn