You create a line in the first and second cases:
$a = "1"; //string with "1" character on index 0 $a[$a] = "2"; //on second index you put "2". The equivalent of the following: $a[1]="2" $a{1}="2" $a[1]=2 $a{1}=2;
Since you use it as a string, 2 used as a string, so cases 1 and 2 give the same result.
Similarly, in the first case, when you use the string "1" as an index, it is converted to an integer in $a[$a] .
In the latter case, $a is an integer, you cannot add characters to the next position, as in the string
source share