Home > Backend Development > PHP Tutorial > Let's get to know YAML together: Introduction to YAML_PHP Tutorial

Let's get to know YAML together: Introduction to YAML_PHP Tutorial

WBOY
Release: 2016-07-13 17:29:42
Original
1175 people have browsed it

YAML

Definition from the YAML official website (http://www.yaml.org/): YAML is an intuitive data serialization format that can be recognized by computers. It is easy to be read by humans and easy to use with scripts. Language is interactive. In other words, YAML is a very simple data description language similar to XML, and its syntax is much simpler than XML. It is very useful for describing data that can be converted into an array or hash, such as:

$house = array(
family => array(
name => Doe,
parents => array(John, Jane),
children => array(Paul , Mark, Simone)
),
address => array(
number => 34,
street => Main Street,
city => Nowheretown,
zipcode => 12345
)
);

Parsing this YAML will automatically create the following PHP array:

house:
family:
name: Doe
parents:
- John
- Jane
children:
- Paul
- Mark
- Simone
address:
number: 34
street: Main Street
city: Nowheretown
zipcode: 12345

In YAML, structures are represented by indentation, consecutive items are represented by minus signs "-", and key/value pairs in the map structure are separated by colons ":". YAML also has abbreviated syntax for describing several lines of data with the same structure. Arrays are enclosed by [], and hashes are enclosed by {}. Therefore, the previous YAML can be abbreviated as follows:

house:
family: { name: Doe, parents: [John, Jane], children: [Paul, Mark, Simone] }
address: { number: 34, street: Main Street, city: Nowheretown, zipcode: 12345 }

YAML is the abbreviation of "Yet Another Markup Language", pronounced "yamel", or "yamel". This format appeared around 2001, and there are already YAML parsers for multiple languages.

Tips The detailed specifications of YAML format can be found on the YAML official website http://www.yaml.org/.

As you can see, writing YAML is much faster than XML (no closing tags or quotes required), and more powerful than .ini files (ini files do not support hierarchies). So symfony chooses YAML as the preferred format for configuration information. You'll see a lot of YAML files in this book, but it's intuitive enough that you don't need to delve deeper into YAML.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/531669.htmlTechArticleYAML Definition from the YAML official website (http://www.yaml.org/): YAML is a Intuitive data serialization format that can be recognized by computers. It is easy to be read by humans and easy to communicate with...
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