3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test_type(mixed $value, string $type) { if (in_array(($actual = gettype($value)), ['string', 'integer', 'NULL'])) { if (str_contains($type, '?') && $actual === 'NULL') return true; return $actual === $type; } return in_array(true, array_map(fn(string $x) => $value instanceof $x, explode('|', $type))); } echo (int) test_type(null, "int"); echo (int) test_type(null, "?int"); echo (int) test_type("hello, world", "bool"); echo (int) test_type(new DateTime, "DateTimeInterface"); echo (int) test_type(new DateTime, "null|int|DateTime|DateTimeImmutable");

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.5.30.0080.01019.23
8.5.20.0110.00920.23
8.5.10.0170.00416.63
8.5.00.0130.00820.31
8.4.180.0120.01122.06
8.4.170.0160.00723.99
8.4.160.0120.00824.05
8.4.150.0070.00517.03
8.4.140.0150.00617.75
8.4.130.0140.00617.96
8.4.120.0160.00420.73
8.4.110.0110.00818.94
8.4.100.0120.00918.09
8.4.90.0110.01017.79
8.4.80.0030.00518.07
8.4.70.0160.00219.77
8.4.60.0080.01219.71
8.4.50.0150.00620.06
8.4.40.0130.00617.99
8.4.30.0040.01422.34
8.4.20.0130.00719.23
8.4.10.0040.00419.80
8.3.300.0120.00821.00
8.3.290.0160.00418.70
8.3.280.0140.00618.83
8.3.270.0100.01016.58
8.3.260.0120.00716.84
8.3.250.0090.00919.07
8.3.240.0120.00616.86
8.3.230.0070.01316.55
8.3.220.0100.00817.51
8.3.210.0120.00717.09
8.3.200.0130.00919.04
8.3.190.0130.00817.13
8.3.180.0120.00719.15
8.3.170.0070.01417.03
8.3.160.0090.00918.80
8.3.150.0160.00317.34
8.3.140.0040.00416.84
8.3.130.0160.00318.60
8.3.120.0180.00018.49
8.3.110.0140.00418.65
8.3.100.0100.01018.33
8.3.90.0210.00316.72
8.3.80.0170.00616.73
8.3.70.0190.00318.42
8.3.60.0170.00516.40
8.3.50.0240.00018.54
8.3.40.0170.00317.57
8.3.30.0070.01117.65
8.3.20.0200.00019.43
8.3.10.0140.00517.44
8.3.00.0050.00717.64
8.2.300.0080.01318.81
8.2.290.0110.00820.23
8.2.280.0130.00616.78
8.2.270.0070.01316.77
8.2.260.0150.00317.05
8.2.250.0030.00517.01
8.2.240.0120.00818.45
8.2.230.0170.00316.63
8.2.220.0150.00318.50
8.2.210.0150.00316.43
8.2.200.0120.00618.28
8.2.190.0190.00016.74
8.2.180.0180.00018.45
8.2.170.0130.00717.64
8.2.160.0140.00617.88
8.2.150.0150.00517.47
8.2.140.0150.00417.45
8.2.130.0150.00417.51
8.2.120.0170.00319.32
8.2.110.0240.00017.35
8.2.100.0110.00817.65
8.2.90.0160.00317.76
8.2.80.0170.00417.19
8.2.70.0160.00517.28
8.2.60.0120.00817.45
8.2.50.0170.00317.63
8.2.40.0190.00017.54
8.2.30.0160.00317.70
8.2.20.0120.00617.54
8.2.10.0150.00217.50
8.2.00.0130.00617.58
8.1.340.0090.01017.94
8.1.330.0120.00816.85
8.1.320.0130.00517.98
8.1.310.0030.00618.74
8.1.300.0140.00518.03
8.1.290.0100.00716.10
8.1.280.0140.00516.05
8.1.270.0190.00017.48
8.1.260.0190.00017.48
8.1.250.0170.00219.38
8.1.240.0130.00417.20
8.1.230.0140.00217.06
8.1.220.0100.00717.15
8.1.210.0120.00417.38
8.1.200.0140.00317.25
8.1.190.0100.00817.25
8.1.180.0150.00417.09
8.1.170.0140.00717.23
8.1.160.0170.00217.35
8.1.150.0130.00517.54
8.1.140.0160.00017.29
8.1.130.0130.00517.21
8.1.120.0100.00717.43
8.1.110.0090.00917.54
8.1.100.0090.00918.96
8.1.90.0080.00817.24
8.1.80.0180.00017.15
8.1.70.0140.00217.19
8.1.60.0160.00317.46
8.1.50.0100.00717.23
8.1.40.0130.00817.28
8.1.30.0070.01117.54
8.1.20.0190.00317.24
8.1.10.0100.01017.40
8.1.00.0190.00317.29

preferences:
46.83 ms | 977 KiB | 5 Q