Functions of PHP braces

Source: Internet
Author: User

 

1. No matter what program, function name () {}, (){},.... This is too much, and I know what it is.
2. $ STR {4} after the variable of the string is the same as that of the variable of {}. The variable of the string is treated as an array.
Iii. {$ Val}. At this time, braces are used to tell PHP that the enclosed values should be processed as variables.

$ Arr = array (0 => 123, 'name' => 'pipig ');
Foreach ($ array as $ k => $ v ){
Echo "select * From blog_blogs where blog_tags like '% {$ arr [$ K]} % 'order by blog_id"; // Add a braces that will only be used as a variable identifier
}
Echo '<br/> ';
Foreach ($ array as $ k => $ v ){
Echo "select * From blog_blogs where blog_tags like '% {$ arr [$ K]} % 'order by blog_id"; // Add two braces, the outer layer is a common character.
}
// Use braces to differentiate Variables
// Echo "$ arr ['name']"; // a syntax error is returned when you use this sentence.
Echo "{$ arr ['name']}"; // This sentence is normal. The characters in braces are processed as variables.
// $ STR {4} after the variable of the string, the variable of the string is treated as an array like the braces ({}).
$ STR = 'abcdefg ';
Echo $ STR {4 };

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.