3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); $myArray = [12, 'string value', 'another string value', 5]; var_dump($myArray); array_map('validateMyArrayValues', $myArray); function validateMyArrayValues(string $item) { var_dump($item); }
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
array(4) { [0]=> int(12) [1]=> string(12) "string value" [2]=> string(20) "another string value" [3]=> int(5) } string(2) "12" string(12) "string value" string(20) "another string value" string(1) "5"
Output for 5.6.0 - 5.6.30
Warning: Unsupported declare 'strict_types' in /in/A8MJT on line 3 array(4) { [0]=> int(12) [1]=> string(12) "string value" [2]=> string(20) "another string value" [3]=> int(5) } Catchable fatal error: Argument 1 passed to validateMyArrayValues() must be an instance of string, integer given in /in/A8MJT on line 10
Process exited with code 255.

preferences:
102.93 ms | 1761 KiB | 4 Q