Home >Backend Development >PHP Tutorial >Understanding PHP String Principles_PHP Tutorial
Many times we use PHP strings, and how PHP strings are composed, it is estimated that few people understand this~
In fact, PHP string is a character array. Suppose we define a string
$string ="hello world";
/*
This string is composed of h, e, l, l, o, space, w, o, r, l, d. As for what it ends with, I can understand it now. You may need to check the PHP original Code can be discovered
*/
//What is the basis for what I said above? You can test it below
echo $string[2];//The third character l is displayed, we can try to change
$string[2]="A";//Change one of the characters;
echo $string;// get heAlo world
//Then we can try to change $string[2] to string
$string[2]="AAAAAA";//Test to see if PHP will overwrite the following characters
echo $string;// Get heAlo world , haha. It seems that PHP has done safety processing
?>