PHP string principle example _ PHP Tutorial

Source: Internet
Author: User
Example of PHP string principles. In fact, the PHP string principle is the character array. suppose we define a string? $ Stringhelloworld; * this string is composed of h, e, l, l, o, space, w, o, r, l, d.In fact, the PHP string principle is the character array. suppose we define a string.

  1. <?
  2. $ String = "hello world ";
  3. /*
  4. This string is composed of h, e, l, l, o, and spaces.
    , W, o, r, l, d.
    At the end, I can understand it now. I may need to check the original PHP code to explore it.
  5. */
  6. // What is the basis of what I mentioned above? The following can be tested:
  7. Echo $ string [2];
    // The display contains 3rd characters, which can be changed.
  8. $ String [2] = "";
    // Change one of the characters;
  9. Echo $ string;
    // Get heAlo world
  10. // We can change it to $ string [2]
  11. $ String [2] = "AAAAAA ";
    // Test whether PHP will overwrite the subsequent characters
  12. Echo $ string;
    // Get heAlo world.
  13. ?>

How can I clearly understand the principles of PHP strings through the above code examples? You can learn from the actual operations in the future.


In fact, the PHP string principle is the character array. suppose we define a string? $ String = helloworld;/* This string is composed of the characters h, e, l, l, o, space, w, o, r, l, d...

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.