Are php strings immutable ?



PHP strings can be changed, but the most common practice seems to be to treat strings as immutable.Strings can be changed by treating them as character arrays and assigning directly into them, like this:
$my_string = “abcdefg”;
$my_string[5] = “X”;
print($my_string . “
”);
which will give the browser output:
abcdeXg
?>



Comments are closed.