1<?php 2 3//$container var declaration in const generated file 4 5// Read before write 6try { 7 echo "Read before write:\n"; 8 var_dump($container[$dimension]); 9} catch (\Throwable $e) { 10 echo $e->getMessage(), "\n"; 11} 12// Write 13try { 14 echo "Write:\n"; 15 $container[$dimension] = 5; 16} catch (\Throwable $e) { 17 echo $e->getMessage(), "\n"; 18} 19// Read 20try { 21 echo "Read:\n"; 22 var_dump($container[$dimension]); 23} catch (\Throwable $e) { 24 echo $e->getMessage(), "\n"; 25} 26// Read-Write 27try { 28 echo "Read-Write:\n"; 29 $container[$dimension] += 20; 30} catch (\Throwable $e) { 31 echo $e->getMessage(), "\n"; 32} 33// Is 34try { 35 echo "isset():\n"; 36 var_dump(isset($container[$dimension])); 37} catch (\Throwable $e) { 38 echo $e->getMessage(), "\n"; 39} 40try { 41 echo "empty():\n"; 42 var_dump(empty($container[$dimension])); 43} catch (\Throwable $e) { 44 echo $e->getMessage(), "\n"; 45} 46try { 47 echo "null coalesce:\n"; 48 var_dump($container[$dimension] ?? 'default'); 49} catch (\Throwable $e) { 50 echo $e->getMessage(), "\n"; 51} 52// Fetch reference 53try { 54 echo "Reference to dimension:\n"; 55 $r = &$container[$dimension]; 56 echo "Value of reference:\n"; 57 var_dump($r); 58 $r = 100; 59 echo "Value of container dimension after write to reference (should be int(100) if successful):\n"; 60 var_dump($container[$dimension]); 61} catch (\Throwable $e) { 62 echo $e->getMessage(), "\n"; 63} 64// Unset 65try { 66 echo "unset():\n"; 67 unset($container[$dimension]); 68} catch (\Throwable $e) { 69 echo $e->getMessage(), "\n"; 70} 71// Nested read 72try { 73 echo "Nested read:\n"; 74 var_dump($container[$dimension][$dimension]); 75} catch (\Throwable $e) { 76 echo $e->getMessage(), "\n"; 77} 78// Nested write 79try { 80 echo "Nested write:\n"; 81 $container[$dimension][$dimension] = 5; 82} catch (\Throwable $e) { 83 echo $e->getMessage(), "\n"; 84} 85// Nested Read-Write 86try { 87 echo "Nested Read-Write:\n"; 88 $container[$dimension][$dimension] += 25; 89} catch (\Throwable $e) { 90 echo $e->getMessage(), "\n"; 91} 92// Nested Is 93try { 94 echo "Nested isset():\n"; 95 var_dump(isset($container[$dimension][$dimension])); 96} catch (\Throwable $e) { 97 echo $e->getMessage(), "\n"; 98} 99try { 100 echo "Nested empty():\n"; 101 var_dump(empty($container[$dimension][$dimension])); 102} catch (\Throwable $e) { 103 echo $e->getMessage(), "\n"; 104} 105try { 106 echo "Nested null coalesce:\n"; 107 var_dump($container[$dimension][$dimension] ?? 'default'); 108} catch (\Throwable $e) { 109 echo $e->getMessage(), "\n"; 110} 111// Nested unset 112try { 113 echo "Nested unset():\n"; 114 unset($container[$dimension][$dimension]); 115} catch (\Throwable $e) { 116 echo $e->getMessage(), "\n"; 117} 118