Last active
April 12, 2016 07:59
-
-
Save tamakiii/9455b7b645c0adb3c594 to your computer and use it in GitHub Desktop.
How list() works.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
<?php | |
$data = [ | |
'[1,2]' => [1, 2], | |
'[]' => [], | |
'[null,null]' => [null, null], | |
'null' => null, | |
"''" => '', | |
'1' => 1, | |
'true' => true, | |
'false' => false, | |
]; | |
echo 'error_reporting: '; | |
var_dump(error_reporting()); | |
echo PHP_EOL; | |
foreach ($data as $key => $row) { | |
echo '#' . $key . PHP_EOL; | |
list($a, $b) = $row; | |
var_dump($a, $b); | |
echo PHP_EOL; | |
echo '---'; | |
echo PHP_EOL; | |
} | |
// error_reporting: int(22527) | |
// | |
// #[1,2] | |
// int(1) | |
// int(2) | |
// | |
// --- | |
// #[] | |
// PHP Notice: Undefined offset: 1 in /Users/d-tamaki/tmp/php/list.php on line 21 | |
// PHP Stack trace: | |
// PHP 1. {main}() /Users/d-tamaki/tmp/php/list.php:0 | |
// PHP Notice: Undefined offset: 0 in /Users/d-tamaki/tmp/php/list.php on line 21 | |
// PHP Stack trace: | |
// PHP 1. {main}() /Users/d-tamaki/tmp/php/list.php:0 | |
// NULL | |
// NULL | |
// | |
// --- | |
// #[null,null] | |
// NULL | |
// NULL | |
// | |
// --- | |
// #null | |
// NULL | |
// NULL | |
// | |
// --- | |
// #'' | |
// PHP Notice: Uninitialized string offset: 1 in /Users/d-tamaki/tmp/php/list.php on line 21 | |
// PHP Stack trace: | |
// PHP 1. {main}() /Users/d-tamaki/tmp/php/list.php:0 | |
// PHP Notice: Uninitialized string offset: 0 in /Users/d-tamaki/tmp/php/list.php on line 21 | |
// PHP Stack trace: | |
// PHP 1. {main}() /Users/d-tamaki/tmp/php/list.php:0 | |
// string(0) "" | |
// string(0) "" | |
// | |
// --- | |
// #1 | |
// NULL | |
// NULL | |
// | |
// --- | |
// #true | |
// NULL | |
// NULL | |
// | |
// --- | |
// #false | |
// NULL | |
// NULL | |
// | |
// --- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment