3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( 'fromWeightkg', 'toWeightkg', 'value', 1, 0, '1', '0', ); foreach ($array as $value) { var_dump(gr($value)); } function gr($str) { $str[0] = strtoupper($str[0]); return $str; }
Output for 8.3.0 - 8.3.6
string(12) "FromWeightkg" string(10) "ToWeightkg" string(5) "Value" Warning: Trying to access array offset on int in /in/QiZhG on line 17 Deprecated: strtoupper(): Passing null to parameter #1 ($string) of type string is deprecated in /in/QiZhG on line 17 Fatal error: Uncaught Error: Cannot use a scalar value as an array in /in/QiZhG:17 Stack trace: #0 /in/QiZhG(13): gr(1) #1 {main} thrown in /in/QiZhG on line 17
Process exited with code 255.
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
string(12) "FromWeightkg" string(10) "ToWeightkg" string(5) "Value" Warning: Trying to access array offset on value of type int in /in/QiZhG on line 17 Deprecated: strtoupper(): Passing null to parameter #1 ($string) of type string is deprecated in /in/QiZhG on line 17 Fatal error: Uncaught Error: Cannot use a scalar value as an array in /in/QiZhG:17 Stack trace: #0 /in/QiZhG(13): gr(1) #1 {main} thrown in /in/QiZhG on line 17
Process exited with code 255.
Output for 8.0.0 - 8.0.30
string(12) "FromWeightkg" string(10) "ToWeightkg" string(5) "Value" Warning: Trying to access array offset on value of type int in /in/QiZhG on line 17 Fatal error: Uncaught Error: Cannot use a scalar value as an array in /in/QiZhG:17 Stack trace: #0 /in/QiZhG(13): gr(1) #1 {main} thrown in /in/QiZhG on line 17
Process exited with code 255.
Output for 7.4.0 - 7.4.33
string(12) "FromWeightkg" string(10) "ToWeightkg" string(5) "Value" Notice: Trying to access array offset on value of type int in /in/QiZhG on line 17 Warning: Cannot use a scalar value as an array in /in/QiZhG on line 17 int(1) Notice: Trying to access array offset on value of type int in /in/QiZhG on line 17 Warning: Cannot use a scalar value as an array in /in/QiZhG on line 17 int(0) string(1) "1" string(1) "0"
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.6 - 7.2.33, 7.3.16 - 7.3.33
string(12) "FromWeightkg" string(10) "ToWeightkg" string(5) "Value" Warning: Cannot use a scalar value as an array in /in/QiZhG on line 17 int(1) Warning: Cannot use a scalar value as an array in /in/QiZhG on line 17 int(0) string(1) "1" string(1) "0"

preferences:
184.17 ms | 405 KiB | 312 Q