PHP array key values use single and double quotes and unsigned differences
Method/Step
- 1
The first: $array [' key '] This single quote key value pattern can be parsed directly into an array that is $array
The second type: $array ["key"] this double-quote key-value pattern, the first execution is "key", to determine whether there is a defined PHP variable exists, parsing the array is $array
Third: $array [key] This is a no single double quote key value mode, which first parses the presence of a constant that has a key key value definition, that is, using define (' key ', ' Val '), and then parsing the array as $array
- 2
Other conditions: For example $array["$a"] and $array[$a] differences
1. $array ["$a"], $array [$a] in this case, the value of the array is parsed by the array subscript of the string type
2. $array ["$a"], $array [$a] This situation has no meaning if the index type is an array
3. $array ["$a"], $array [$a] This situation can not care about single double quotes, stating that $ A is a variable, that is $array["$a"]=== $array [$a]
- 3
Detailed Examples:
<?php
Define (' Chang ', ' array1 ');
$chang = ' $array 2 ';
$bian = ' array1 ';
$array = Array (
' Array1 ' = ' array1 ',
' $array 2 ' = ' $array 2 ',
' $array 3 ' = ' $array 3 ',
);
echo $array [' array1 ']. ' <br/> ';
echo $array ["$bian"], ' <br/> ';
Echo $array [Chang], ' <br/> ';
echo $array [$chang];
PHP array key values use single and double quotes and unsigned differences