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.
- <?
- $ String = "hello world ";
- /*
- 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.
- */
- // What is the basis of what I mentioned above? The following can be tested:
- Echo $ string [2];
// The display contains 3rd characters, which can be changed.
- $ String [2] = "";
// Change one of the characters;
- Echo $ string;
// Get heAlo world
- // We can change it to $ string [2]
- $ String [2] = "AAAAAA ";
// Test whether PHP will overwrite the subsequent characters
- Echo $ string;
// Get heAlo world.
- ?>
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...