What does braces {} in php mean? _ PHP Tutorial

Source: Internet
Author: User
What is the meaning of braces {} in php. 1. {} indicates the start and end of the program block. for example, the code for copying code is as follows: if ($ x $ y) {do_nothing ();} 2. {} is used to indicate the string subscript. for example, $1 and {} are used to indicate the start and end of the program block.

For example

The code is as follows:


If ($ x = $ y)
{
Do_nothing ();
}


2. {} indicates the subscript of a string.

For example
(Reference longnetpro)
$ S {1} indicates the 2nd bytes (not the first) of the string $ s. It is basically equivalent to $ s [1], but the latter is the old one, PHP Manual recommends the first method: www.444p.com All rights reserved

3. separate variables

For example

The code is as follows:


$ S = "Di ,";
Echo ("$ {s} omething ");
// Output: Di, omething


If echo ("$ something") is used ");
Then the variable $ something is output.

Else {} indicates the start and end of the program block. for example, the code is as follows: if ($ x = $ y) {do_nothing ();} 2. {} indicates the string subscript. for example, if you reference the longnetpro brother, $...

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.