What do you know about the role of PHP curly braces?

Source: Internet
Author: User
  1. !--? php /**
  2. *php curly braces Cases Urealyticum
  3. *site http://bbs.it-home.org
  4. */
  5. $arr =array (0=>123, ' name ' = ' piglet ');
  6. foreach ($array as $k = $v) {
  7. echo "select * from Blog_blogs where blog_tags like '%{$arr [$k]}% ' ORDER BY BLOG_ID "; Add a curly brace just as the marker for the variable
  8. }
  9. echo '






    ';
  10. foreach ($array as $k = $v) {
  11. echo "select * from Blog_blogs where blog_tags like '%{{$arr [$k]}}% ' order by blog_id "; Add two curly braces, the outer layer will be the normal character
  12. }
  13. //curly braces to differentiate the variable
  14. //echo "$arr [' name ']";//Use this sentence to report grammatical errors
  15. Echo "{$arr [' name ']}";//This sentence is normal, the characters in the curly braces will be treated as variables
  16. //$STR {4} After the variable of the string, the {} curly braces and the brackets are the same as the string variable as the array processing
  17. $str = ' ABCDEFG ';
  18. echo $str {4};
  19. ?
copy code
  • 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.