php 解析yml

WBOY
Release: 2016-06-20 12:29:17
Original
2453 people have browsed it

在 配置 项目时,遇到了 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);}
Copy after login




Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template