In PHP, a string is an array of bytes. Use curly braces and numeric subscripts to access or modify the corresponding single character in the string. Note that it is a single character!
$str{1} in your code can only hold one character, and your assignment is 5 characters. At this time, php will only take the first character by default, so its result will naturally be lnmp.
In addition, the official PHP documentation also says that using curly braces to access or modify strings is very unsafe for multi-byte character sets. Try not to use {} when you use other encoding sets such as UTF-8 or GBK.
A string string is composed of a series of characters, where each character is equivalent to one byte. This means that PHP can only support a character set of 256 and therefore does not support Unicode. See the detailed explanation of string types for details.
Quoted from the PHP manual. Indicated in bold. Each character is a byte. Therefore, only one byte position can be replaced.
In PHP, a string is an array of bytes. Use curly braces and numeric subscripts to access or modify the corresponding single character in the string. Note that it is a single character!
$str{1} in your code can only hold one character, and your assignment is 5 characters. At this time, php will only take the first character by default, so its result will naturally be lnmp.
In addition, the official PHP documentation also says that using curly braces to access or modify strings is very unsafe for multi-byte character sets. Try not to use {} when you use other encoding sets such as UTF-8 or GBK.
A string string is composed of a series of characters, where each character is equivalent to one byte. This means that PHP can only support a character set of 256 and therefore does not support Unicode. See the detailed explanation of string types for details.
Quoted from the PHP manual. Indicated in bold. Each character is a byte. Therefore, only one byte position can be replaced.