Home php教程 php手册 让我们一起认识YAML:YAML简介

让我们一起认识YAML:YAML简介

Jun 13, 2016 am 10:29 AM
http yaml Official website definition us yes of Introduction

YAML

来自YAML官方网站 (http://www.yaml.org/) 的定义: YAML是一种直观的能够被电脑识别的的数据数据序列化格式,它并且容易被人类阅读,容易与脚本语言交互的。换种说法,YAML是一种非常简单的类似于XML的数据描述语言,语法比XML简单很多。他在描述可以被转化成数组或者hash的数据是非常有用,例如:

$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
  )
);

解析这个YAML将会自动创建下面的PHP数组:

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

在YAML里面,结构通过缩进来表示,连续的项目通过减号"-"来表示,map结构里面的key/value对用冒号":"来分隔。YAML也有用来描述好几行相同结构的数据的缩写语法,数组用[]包括起来,hash用{}来包括。因此,前面的这个YAML可以缩写成这样:

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

YAML是"Yet Another Markup Language(另一种标记语言)"的缩写,读音"yamel",或者"雅梅尔"。这种格式大约是2001年出现的,目前为止已经有多种语言的YAML解析器。

提示 YAML格式的详细规格可以在YAML官方网站http://www.yaml.org/找到。

如你所见,写YAML要比XML快得多(不需要关闭标签或者引号),并且比.ini文件功能更强(ini文件不支持层次)。所以symfony选择YAML作为配置信息的首选格式。在本书你会看到很多YAML文件,不过它很直观你用不着更深入地研究YAML。


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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is Discuz? Definition and function introduction of Discuz What is Discuz? Definition and function introduction of Discuz Mar 03, 2024 am 10:33 AM

"Exploring Discuz: Definition, Functions and Code Examples" With the rapid development of the Internet, community forums have become an important platform for people to obtain information and exchange opinions. Among the many community forum systems, Discuz, as a well-known open source forum software in China, is favored by the majority of website developers and administrators. So, what is Discuz? What functions does it have, and how can it help our website? This article will introduce Discuz in detail and attach specific code examples to help readers learn more about it.

The definition and function of MySQL composite primary key The definition and function of MySQL composite primary key Mar 15, 2024 pm 05:18 PM

The composite primary key in MySQL refers to the primary key composed of multiple fields in the table, which is used to uniquely identify each record. Unlike a single primary key, a composite primary key is formed by combining the values ​​of multiple fields. When creating a table, you can define a composite primary key by specifying multiple fields as primary keys. In order to demonstrate the definition and function of composite primary keys, we first create a table named users, which contains three fields: id, username and email, where id is an auto-incrementing primary key and user

Python ORM Performance Benchmark: Comparing Different ORM Frameworks Python ORM Performance Benchmark: Comparing Different ORM Frameworks Mar 18, 2024 am 09:10 AM

Object-relational mapping (ORM) frameworks play a vital role in python development, they simplify data access and management by building a bridge between object and relational databases. In order to evaluate the performance of different ORM frameworks, this article will benchmark against the following popular frameworks: sqlAlchemyPeeweeDjangoORMPonyORMTortoiseORM Test Method The benchmarking uses a SQLite database containing 1 million records. The test performed the following operations on the database: Insert: Insert 10,000 new records into the table Read: Read all records in the table Update: Update a single field for all records in the table Delete: Delete all records in the table Each operation

'Langlang Dubbing' official website entrance link 'Langlang Dubbing' official website entrance link Mar 01, 2024 pm 07:49 PM

Langlang Dubbing is a free text-to-speech tool that provides speech synthesis services and supports multiple languages, including Chinese, English, German, French, Italian, Spanish, Indonesian and more than 30 languages, as well as multiple voice styles. . Where is the official website of Langlang Dubbing? Where can you try this tool? Next, I will share with you the link to the official website of Langlang Dubbing. If you need it, come quickly! "Langlang Dubbing" official website entrance link Official website entrance link: https://www.lang123.top/ Advantages of Langlang Dubbing and other dubbing functions, as well as the synthesis method of multiple dubbing people. Easy to operate and easy to use

Introduction to PHP interfaces and how to define them Introduction to PHP interfaces and how to define them Mar 23, 2024 am 09:00 AM

Introduction to PHP interface and how it is defined. PHP is an open source scripting language widely used in Web development. It is flexible, simple, and powerful. In PHP, an interface is a tool that defines common methods between multiple classes, achieving polymorphism and making code more flexible and reusable. This article will introduce the concept of PHP interfaces and how to define them, and provide specific code examples to demonstrate their usage. 1. PHP interface concept Interface plays an important role in object-oriented programming, defining the class application

Application of Python ORM in big data projects Application of Python ORM in big data projects Mar 18, 2024 am 09:19 AM

Object-relational mapping (ORM) is a programming technology that allows developers to use object programming languages ​​to manipulate databases without writing SQL queries directly. ORM tools in python (such as SQLAlchemy, Peewee, and DjangoORM) simplify database interaction for big data projects. Advantages Code Simplicity: ORM eliminates the need to write lengthy SQL queries, which improves code simplicity and readability. Data abstraction: ORM provides an abstraction layer that isolates application code from database implementation details, improving flexibility. Performance optimization: ORMs often use caching and batch operations to optimize database queries, thereby improving performance. Portability: ORM allows developers to

How to implement HTTP streaming using C++? How to implement HTTP streaming using C++? May 31, 2024 am 11:06 AM

How to implement HTTP streaming in C++? Create an SSL stream socket using Boost.Asio and the asiohttps client library. Connect to the server and send an HTTP request. Receive HTTP response headers and print them. Receives the HTTP response body and prints it.

The definition and use of full-width characters The definition and use of full-width characters Mar 25, 2024 pm 03:33 PM

What are full-width characters? In computer encoding systems, double-width characters are a character encoding method that takes up two standard character positions. Correspondingly, the character encoding method that occupies a standard character position is called a half-width character. Full-width characters are usually used for input, display and printing of Chinese, Japanese, Korean and other Asian characters. In Chinese input methods and text editing, the usage scenarios of full-width characters and half-width characters are different. Use of full-width characters Chinese input method: In the Chinese input method, full-width characters are usually used to input Chinese characters, such as Chinese characters, symbols, etc.

See all articles