Describes the composition of PHP Strings

Source: Internet
Author: User

In progressIn fact, PHP Strings are character arrays. Suppose we define a string.

 
  1. <? 
  2.  
  3. $String="Hello world";
  4.  
  5. /*
  6.  
  7. This PHP string is composed of the characters h, e, l, l, o, space, w, o, r, l, and d. As for the end, I can understand it now, you may need to check the original PHP code to explore it.
  8.  
  9. */
  10.  
  11. // What is the basis of what I mentioned above? The following can be tested:
  12.  
  13. Echo $ string [2]; // 3rd character l is displayed. We can try to change it.
  14.  
  15. $ String [2] = "A"; // modify A character;
  16.  
  17. Echo $ string; // obtain heAlo world
  18.  
  19. // We can change it to $ string [2]
  20.  
  21. $ String [2] = "AAAAAA"; // test whether PHP will overwrite the subsequent characters.
  22.  
  23. Echo $ string; // get heAlo world.
  24.  
  25. ?> 

I hope you can thoroughly understand the composition principles of PHP Strings through the code above.


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.