PHP Syntax design arrays Why not use the universal {} curly braces? Other programming languages are included in the array's initial values in curly braces {}.

Source: Internet
Author: User
Tags array definition
PHP can only be used array= (), in the new version of the phrase used in the square brackets []. Is the curly brace {} not more in line with the general public?
C # int[] array = {1, 2, 3, 4, 5, 6};
Java int[] arr = {0,0,0,0,0,0,0,0,0,0,0,};
Python () tuple [] List/Array {} The dictionary is not mixed into a,,, Python is a little relative to PHP. []
Golang arr:=[...] int{1,1,1,1,1,1,1,1,1}

Are all curly braces {} contain,,,

PHP uses [] in parentheses, is it the original because {} curly braces have some special uses in PHP $a = "aaaaaa{$b}aaaaaa"; Afraid to create ambiguity? , or it is easier to knock [] the brackets than the bridge {} curly braces, without the SHIFT key.
The Blind guess!!! Just don't know how to deal with the inside of the PHP development Group for what reason, use [] square brackets, without {} curly braces.

Curly braces are big! Big! Parentheses,,, PHP, this data structure is mixed, curly braces, the largest brackets,, haha,, anything can be enclosed, curly braces {} This symbol graphics feel also meet the visual requirements.

Reply content:

PHP can only be used array= (), in the new version of the phrase used in the square brackets []. Is the curly brace {} not more in line with the general public?
C # int[] array = {1, 2, 3, 4, 5, 6};
Java int[] arr = {0,0,0,0,0,0,0,0,0,0,0,};
Python () tuple [] List/Array {} The dictionary is not mixed into a,,, Python is a little relative to PHP. []
Golang arr:=[...] int{1,1,1,1,1,1,1,1,1}

Are all curly braces {} contain,,,

PHP uses [] in parentheses, is it the original because {} curly braces have some special uses in PHP $a = "aaaaaa{$b}aaaaaa"; Afraid to create ambiguity? , or it is easier to knock [] the brackets than the bridge {} curly braces, without the SHIFT key.
The Blind guess!!! Just don't know how to deal with the inside of the PHP development Group for what reason, use [] square brackets, without {} curly braces.

Curly braces are big! Big! Parentheses,,, PHP, this data structure is mixed, curly braces, the largest brackets,, haha,, anything can be enclosed, curly braces {} This symbol graphics feel also meet the visual requirements.

It's strange to use curly braces, in the mathematical context, {} stands for the collection, [] represents the list, the collection is not sequential, and the list is ordered. So more and more modern languages use [] to represent the list.

Supplementary @yetone Answer:

PHP之前很多年数组的表示形式一直是 array(),而 [ ] 方式是在PHP5.4中才引入的。如果你写过一段时间PHP,你就会发现用 [ ] 表示数组也是你内心真正想的一件事,这是顺其自然的。

And there's an array () It's too much to write, okay?

PHP的数组根本就不是传统的C数组,而是 map、链表、堆、栈......

You can use the short array definition syntax since 5.4 to replace array () with [].
Programming languages typically use [] to represent arrays or queues, and {} to represent dictionaries or collections.
In fact, in PHP, arrays can represent dictionaries because they are key-value pairs. So the main idea was to use {}.

The latest version of php5.4+ has been supported, but with few people. Most of them are PHP 5.2,php5.3.3

[] In the PHP5.4 has started to support, and not so the language definition array are used {}, such as JS

An array of PHP is actually a dictionary, so you can't use an array of other languages to compare it to a dictionary.

The Dictionary of PY is {}
The object of JS is {}
Swift's Dictionary is [:]

It seems that the newly emerging language tends to use brackets
And php5.4 is newer, so use the brackets

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.