note 119765 rejected from migration70.new-features by cmb
| From: | cmb@php.net | Date: | Sat, 20 Aug 2016 09:30:55 +0000 |
| Subject: | note 119765 rejected from migration70.new-features by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-206337@lists.php.net to get a copy of this message | ||
Note Submitter: prpanto at gmail dot com
----
Test with define array
test a)
define('ANIMALS', [
'dog' => [
'Bob'
],
'cat',
'bird'
]);
echo ANIMALS[1]; // bird
echo ANIMALS[1][0]; // b
echo ANIMALS[1][1]; // i
echo ANIMALS[1][2]; // r
echo ANIMALS[1][3]; // d
echo ANIMALS[1][4]; // error: Uninitialized string offset: 4
echo ANIMALS[0]; // cat
echo ANIMALS[0][0]; // c
echo ANIMALS[0][1]; // a
echo ANIMALS[0][2]; // t
echo ANIMALS[0][3]; // error: Uninitialized string offset: 4
i try to echo dog but the output is error.
test b)
define('ANIMALS', [
'dog' => [
'Bob'
],
'cat' => [
'Alice'
],
'bird' => [
'Max'
]
]);
echo ANIMALS[0]; // error: Undefined offset: 0
echo ANIMALS[1]; // error: Undefined offset: 1
echo ANIMALS[2]; // error: Undefined offset: 2
echo ANIMALS[3]; // error: Undefined offset: 3