xref: /PHP-8.3/Zend/tests/dim_assign_001.phpt (revision 526c624d)
1--TEST--
2JIT - Assigning to arrays using string key which parses to an integer
3--FILE--
4<?php
5/* We are going to store a value in an array, using the key "1"
6 * PHP should always convert such strings to integers when storing or retrieving
7 * values from an array
8 *
9 * We'll do it in a loop, so that if JIT is enabled, the code will be JIT'd
10 * (Because this test was originally added as a regression test for a JIT bug)
11 *
12 * Also, the test will do this in a way which guarantees PHP won't be able to
13 * predict whether the (string) key will be a numeric string or not */
14$fp = fopen(realpath(__DIR__ . '/dim_assign_001.txt'), 'r+');
15$array = array();
16while ($line = fgets($fp, 256)) {
17  sscanf($line, '%x', $char);
18  $char = chr($char);
19  $array[$char] = "Values can be stored correctly using numeric string keys";
20}
21var_dump($array['1']);
22?>
23--EXPECT--
24string(56) "Values can be stored correctly using numeric string keys"
25