list()modification
1. list() no longer assigns values in reverse order
list($array[], $array[], $array[]) = [1, 2, 3]; var_dump($array);
The above code will return an array: $array == [1, 2, 3] instead of before [3, 2, 1]
Note: Only the order of assignment changes, the assigned value is still the same as the original.
list($a, $b, $c) = [1, 2, 3]; // $a = 1; $b = 2; $c = 3;
The behavior is still the same as the original.
2. Empty list() assignment is no longer allowed.
list() = $a; list(,,) = $a; list($x, list(), $y) = $a;
The above codes will report an error when running.
3. list() no longer supports the string splitting function
$string = "xy"; list($x, $y) = $string;The final result of this code is: $x == null and $y == null (there will be no prompt)
The result of PHP5 operation is: $x == "x" and $y == "y".
4. In addition, list() now also applies to array objects:
list($a, $b) = (object) new ArrayObject([0, 1]);PHP7 results: $a == 0 and $b == 1.
PHP5 results: $a == null and $b == null.