PHP output variable enlarges bracket {} function

Source: Internet
Author: User
Tags string strlen variable
PHP output Variable increase bracket, what is this writing? Look at the following code: [PHP] <?php header ("content-type:text/html;   Charset=utf-8 ");   $test = "1 variable 1";   echo "preceded by a String AA". $test. "BB Back string";   echo "preceded by a string AA {$test} bb back string"; ?> can see that PHP output variable braces are used with the. Operator output variable string effect is the same, summed up the following 3 points to help understand the PHP output variable to increase the parentheses {} function: 1. Represents a variable in {}, which is handled according to the variable when executed; 2. Refers to the special inclusion of variables used in strings so that you can reduce the amount of code input by not using the. operator; 3. Prevents the variable name from being linked with the following string. Attachment: The function of the brace {} in a string variable: The PHP variable is followed by a brace {}, which is filled with numbers, which refers to the character corresponding to the corresponding ordinal of the PHP variable. For example: $str = ' Hello '; echo $str {0}; Output is h echo $str {1}; Output to E If you want to check how long a string is satisfied, consider replacing the strlen function with this brace {} plus isset, because isset is a language structure and strlen is a function, so using isset is more efficient than using strlen. For example, to determine whether a string is less than 5:if (!isset ($str {5})) is better than if (strlen ($STR) < 5).

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.