+ 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 Answers
+ 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
Hot today
I have made a calculator in which my % (Percentage) not work correctly for 100%50 or 100%20.
2 Votes
Python palindrome challenge.
1 Votes
Java
0 Votes
Number of Ones ( C++ ) question!
1 Votes