+ 1
String is called immutable but in this case value of string changed. why ?
? <?php //program to swap the string $name1="Learner"; $name2="Programmer"; $temp=$name1 ; $name1 =$name2 ; $name2 =$temp; echo "name1 =".$name1 ."<br>"; echo "name2 =".$name2 ; ?>
3 ответов
+ 9
$name = "Learner";
$name[0] = "P";
// Error
This code leads to error because you can not change string that way.
+ 4
In fact, you're not changing a string. You're assigning a new string to a variable instead.
+ 2
thanks