3v4l.org

run code in 300+ PHP versions simultaneously
<?php $emailAddr = "test@test.com"; $isDebug = true; // logic stolen shamelessly from an article in linuxjournal.com www.linuxjournal.com/article/9585 // return true if valid, false if not // set the error code to indicate the problem if not // 5 - no '@' found // 10 - email address name is longer than 64 // 15 - email domain name is longer than 64 // 20 - email address name begins or ends with a '.' // 25 - email address name has two consecutive dots '..' // 30 - invalid character in domain // 35 - domain has two consecutive dots '..' // 40 - invalid character in address name // 45 - domain not found in DNS $errorCode = 0; $isValid = true; $atIndex = strrpos($emailAddr, "@"); if (is_bool($atIndex) && !$atIndex) { if ($isDebug) print $emailAddr . "no '@' found<br>"; $errorCode = 5; $isValid = false; } else { $domain = substr($emailAddr, $atIndex+1); $local = substr($emailAddr, 0, $atIndex); $localLen = strlen($local); $domainLen = strlen($domain); if ($localLen < 1 || $localLen > 64) { if ($isDebug) print $emailAddr . " -local part length exceeded<br>"; $errorCode = 10; $isValid = false; } else if ($domainLen < 1 || $domainLen > 255) { if ($isDebug) print $emailAddr . " -domain part length exceeded<br>"; $errorCode = 15; $isValid = false; } else if ($local[0] == '.' || $local[$localLen-1] == '.') { if ($isDebug) print $emailAddr . " -local part starts or ends with '.'<br>"; $errorCode = 20; $isValid = false; } else if (preg_match('/\\.\\./', $local)) { if ($isDebug) print $emailAddr . " -local part has two consecutive dots<br>"; $errorCode = 25; $isValid = false; } else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) { if ($isDebug) print $emailAddr . " -character not valid in domain part<br>"; $errorCode = 30; $isValid = false; } else if (preg_match('/\\.\\./', $domain)) { if ($isDebug) print $emailAddr . " -domain part has two consecutive dots<br>"; $errorCode = 35; $isValid = false; } else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\","",$local))) { if ($isDebug) print $emailAddr . " -character not valid in local part unless local part is quoted<br>"; if (!preg_match('/^"(\\\\"|[^"])+"$/',str_replace("\\\\","",$local))) { $errorCode = 40; $isValid = false; } } } print $isValid; ?>

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.3.60.0070.00718.40
8.3.50.0110.00921.99
8.3.40.0120.00318.92
8.3.30.0040.01119.10
8.3.20.0060.00320.50
8.3.10.0000.00721.91
8.3.00.0080.00018.04
8.2.180.0160.00618.54
8.2.170.0120.00922.96
8.2.160.0130.00322.38
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0030.00526.16
8.2.120.0000.00721.16
8.2.110.0000.00922.22
8.2.100.0090.00717.91
8.2.90.0050.00518.15
8.2.80.0030.00617.97
8.2.70.0060.00317.63
8.2.60.0040.00418.04
8.2.50.0050.00518.07
8.2.40.0000.00818.22
8.2.30.0030.00618.34
8.2.20.0060.00317.95
8.2.10.0040.00418.13
8.2.00.0030.00517.94
8.1.280.0070.01125.92
8.1.270.0040.00423.80
8.1.260.0050.00326.35
8.1.250.0050.00328.09
8.1.240.0080.00422.54
8.1.230.0040.00820.97
8.1.220.0090.00017.89
8.1.210.0050.00319.02
8.1.200.0090.00317.60
8.1.190.0050.00317.25
8.1.180.0080.00018.10
8.1.170.0040.00418.75
8.1.160.0040.00422.02
8.1.150.0040.00418.91
8.1.140.0080.00017.69
8.1.130.0040.00417.82
8.1.120.0000.00717.65
8.1.110.0040.00417.64
8.1.100.0070.00017.62
8.1.90.0040.00417.54
8.1.80.0070.00017.55
8.1.70.0070.00017.63
8.1.60.0060.00317.79
8.1.50.0040.00417.68
8.1.40.0030.00517.74
8.1.30.0060.00317.75
8.1.20.0040.00417.81
8.1.10.0030.00617.77
8.1.00.0000.00817.76
8.0.300.0040.00420.07
8.0.290.0070.00017.13
8.0.280.0000.00718.51
8.0.270.0040.00417.20
8.0.260.0000.00617.34
8.0.250.0030.00317.17
8.0.240.0080.00317.18
8.0.230.0030.00317.05
8.0.220.0070.00017.13
8.0.210.0030.00317.01
8.0.200.0000.00717.06
8.0.190.0070.00017.21
8.0.180.0030.00517.02
8.0.170.0070.00017.04
8.0.160.0040.00416.98
8.0.150.0050.00317.10
8.0.140.0000.00716.97
8.0.130.0040.00413.47
8.0.120.0030.00516.96
8.0.110.0020.00516.95
8.0.100.0000.00817.09
8.0.90.0040.00417.04
8.0.80.0070.01117.04
8.0.70.0000.00717.00
8.0.60.0020.00517.13
8.0.50.0070.00016.97
8.0.30.0120.00817.27
8.0.20.0070.01217.48
8.0.10.0040.00417.25
8.0.00.0070.01416.86
7.4.330.0030.00315.00
7.4.320.0060.00016.68
7.4.300.0000.00616.71
7.4.290.0030.00316.86
7.4.280.0060.00316.65
7.4.270.0050.00316.85
7.4.260.0000.00916.76
7.4.250.0080.00016.82
7.4.240.0060.00216.77
7.4.230.0070.00016.95
7.4.220.0090.00916.97
7.4.210.0070.00716.84
7.4.200.0000.00716.89
7.4.160.0160.00316.84
7.4.150.0140.00317.40
7.4.140.0140.00317.86
7.4.130.0090.01216.74
7.4.120.0100.00716.84
7.4.110.0150.00316.77
7.4.100.0080.00816.86
7.4.90.0100.00716.82
7.4.80.0070.01619.39
7.4.70.0090.00916.69
7.4.60.0100.01016.80
7.4.50.0080.00016.57
7.4.40.0130.00716.63
7.4.30.0100.00716.80
7.4.10.0140.00315.39
7.4.00.0040.01515.13
7.3.330.0050.00013.38
7.3.320.0000.00513.30
7.3.310.0000.00716.48
7.3.300.0000.00716.47
7.3.290.0110.00416.48
7.3.280.0070.01216.50
7.3.270.0070.01017.40
7.3.260.0180.00616.68
7.3.250.0110.00616.63
7.3.240.0060.01216.43
7.3.230.0120.00616.72
7.3.210.0140.00316.82
7.3.200.0150.00619.39
7.3.190.0140.00416.70
7.3.180.0060.00916.73
7.3.170.0030.01316.48
7.3.160.0090.01316.52
7.3.130.0000.01614.91
7.3.120.0100.00414.92
7.3.110.0080.01114.85
7.3.100.0040.01114.99
7.3.90.0080.00515.10
7.3.80.0060.00315.15
7.3.70.0000.01214.94
7.3.60.0050.00914.97
7.3.50.0050.00715.00
7.3.40.0050.00715.04
7.3.30.0080.00614.90
7.3.20.0030.00616.93
7.3.10.0090.00616.60
7.3.00.0080.00916.47
7.2.330.0060.01616.81
7.2.320.0100.01316.91
7.2.310.0060.01116.65
7.2.300.0080.00816.76
7.2.290.0130.00616.82
7.2.260.0070.01015.15
7.2.250.0130.00715.41
7.2.240.0030.01215.23
7.2.230.0030.01415.06
7.2.220.0120.00215.25
7.2.210.0030.00915.11
7.2.200.0050.00515.32
7.2.190.0060.00915.06
7.2.180.0070.00315.27
7.2.170.0080.00515.28
7.2.160.0090.00515.16
7.2.150.0110.00517.05
7.2.140.0070.00717.00
7.2.130.0120.00816.95
7.2.120.0130.00516.79
7.2.110.0070.01016.89
7.2.100.0140.00816.72
7.2.90.0110.00716.82
7.2.80.0080.01117.09
7.2.70.0070.01116.88
7.2.60.0110.00816.88
7.2.50.0090.00916.93
7.2.40.0100.00816.81
7.2.30.0090.01116.87
7.2.20.0120.00816.88
7.2.10.0110.00616.96
7.2.00.0090.00817.51
7.1.330.0060.00915.94
7.1.320.0060.00915.88
7.1.310.0010.00916.01
7.1.300.0060.00915.96
7.1.290.0060.00615.79
7.1.280.0070.00716.03
7.1.270.0060.00915.84
7.1.260.0050.00915.90
7.1.250.0080.00815.80
7.1.240.0040.01116.12
7.1.230.0000.00816.19
7.1.220.0070.00715.84
7.1.210.0070.01016.04
7.1.200.0070.01016.09
7.1.190.0000.01415.98
7.1.180.0030.00615.65
7.1.170.0040.00716.06
7.1.160.0060.00616.14
7.1.150.0040.01116.17
7.1.140.0140.00315.87
7.1.130.0000.00816.13
7.1.120.0060.00315.91
7.1.110.0080.00416.20
7.1.100.0030.01217.33
7.1.90.0030.00716.03
7.1.80.0040.01115.90
7.1.70.0010.00816.79
7.1.60.0080.00817.76
7.1.50.0120.00816.31
7.1.40.0030.01015.98
7.1.30.0030.00616.01
7.1.20.0030.00916.18
7.1.10.0070.00715.86
7.1.00.0060.04119.12
7.0.330.0070.00415.49
7.0.320.0060.01215.60
7.0.310.0040.00415.61
7.0.300.0030.01415.56
7.0.290.0030.00915.36
7.0.280.0030.00715.33
7.0.270.0040.00715.47
7.0.260.0100.00715.46
7.0.250.0060.00915.54
7.0.240.0030.01315.73
7.0.230.0050.00515.70
7.0.220.0060.00615.41
7.0.210.0040.00715.35
7.0.200.0040.00916.19
7.0.190.0040.01515.57
7.0.180.0090.00915.42
7.0.170.0090.00915.84
7.0.160.0030.00815.35
7.0.150.0070.00715.36
7.0.140.0050.04318.97
7.0.130.0040.01115.52
7.0.120.0040.00715.64
7.0.110.0110.00415.42
7.0.100.0070.00715.70
7.0.90.0060.00315.52
7.0.80.0090.00015.59
7.0.70.0070.00715.64
7.0.60.0050.04717.69
7.0.50.0070.02016.80
7.0.40.0050.04616.88
7.0.30.0320.03916.92
7.0.20.0100.02716.85
7.0.10.0150.04716.89
7.0.00.0070.04517.05
5.6.400.0100.00014.44
5.6.390.0070.00714.41
5.6.380.0070.01014.27
5.6.370.0070.00414.62
5.6.360.0030.01014.26
5.6.350.0000.01314.73
5.6.340.0070.00714.82
5.6.330.0060.00314.61
5.6.320.0000.01514.58
5.6.310.0040.00914.49
5.6.300.0060.00914.25
5.6.290.0110.00314.74
5.6.280.0050.04017.75
5.6.270.0000.01114.59
5.6.260.0130.00314.60
5.6.250.0030.01414.38
5.6.240.0100.00314.60
5.6.230.0110.00414.79
5.6.220.0000.01314.79
5.6.210.0080.02517.48
5.6.200.0070.03216.32
5.6.190.0050.04517.47
5.6.180.0030.02517.36
5.6.170.0170.01717.50
5.6.160.0110.02817.26
5.6.150.0050.03816.38
5.6.140.0080.02716.29
5.6.130.0050.04716.36
5.6.120.0060.04317.64
5.6.110.0060.02417.84
5.6.100.0050.04217.74
5.6.90.0100.04217.75
5.6.80.0120.03817.58
5.6.70.0240.02917.26
5.6.60.0030.00914.48
5.6.50.0040.00414.63
5.6.40.0040.01114.27
5.6.30.0060.00614.46
5.6.20.0120.00314.49
5.6.10.0040.01114.51
5.6.00.0070.00414.50
5.5.380.0100.00314.31
5.5.370.0000.01314.45
5.5.360.0060.00914.45
5.5.350.0040.02617.34
5.5.340.0080.04516.16
5.5.330.0090.04217.37
5.5.320.0130.02917.25
5.5.310.0130.03917.35
5.5.300.0030.04916.21
5.5.290.0040.02416.16
5.5.280.0040.04117.64
5.5.270.0050.03817.73
5.5.260.0080.02317.54
5.5.250.0100.03817.52
5.5.240.0070.03817.30
5.5.230.0050.00914.28
5.5.220.0060.00914.21
5.5.210.0090.00614.14
5.5.200.0060.00614.28
5.5.190.0100.00314.19
5.5.180.0110.00614.32
5.5.170.0040.01214.53
5.5.160.0030.00614.19
5.5.150.0120.00314.37
5.5.140.0060.00914.09
5.5.130.0070.00314.30
5.5.120.0070.00714.53
5.5.110.0000.01414.24
5.5.100.0060.00914.13
5.5.90.0070.01014.50
5.5.80.0000.01614.16
5.5.70.0000.01414.63
5.5.60.0030.00614.11
5.5.50.0100.00314.18
5.5.40.0030.01214.29
5.5.30.0000.01814.29
5.5.20.0110.00714.49
5.5.10.0040.00814.58
5.5.00.0030.01014.11
5.4.450.0090.03116.29
5.4.440.0170.02816.44
5.4.430.0100.03016.28
5.4.420.0130.03016.38
5.4.410.0120.04016.13
5.4.400.0210.04116.03
5.4.390.0280.02515.92
5.4.380.0020.03215.98
5.4.370.0020.02915.87
5.4.360.0050.03015.95
5.4.350.0080.02412.62
5.4.340.0070.01912.62
5.4.330.0000.01113.25
5.4.320.0040.02212.86
5.4.310.0070.02112.86
5.4.300.0020.02412.86
5.4.290.0090.01912.86
5.4.280.0050.02312.81
5.4.270.0050.02012.81
5.4.260.0100.01812.81
5.4.250.0050.02412.81
5.4.240.0050.02612.81
5.4.230.0040.02912.80
5.4.220.0080.02512.80
5.4.210.0080.02812.80
5.4.200.0060.02412.80
5.4.190.0070.02412.80
5.4.180.0050.02612.80
5.4.170.0050.02312.81
5.4.160.0050.03012.81
5.4.150.0060.02112.80
5.4.140.0020.02312.65
5.4.130.0030.02212.64
5.4.120.0070.02612.62
5.4.110.0040.02412.62
5.4.100.0060.02312.62
5.4.90.0050.02612.62
5.4.80.0050.02312.61
5.4.70.0060.02412.61
5.4.60.0060.02712.61
5.4.50.0070.02412.61
5.4.40.0070.01912.61
5.4.30.0040.02312.61
5.4.20.0060.01912.61
5.4.10.0080.02112.61
5.4.00.0020.02512.35
5.3.290.0070.02113.02
5.3.280.0060.02112.98
5.3.270.0070.02412.99
5.3.260.0070.02312.98
5.3.250.0060.02112.99
5.3.240.0050.02312.98
5.3.230.0050.02112.98
5.3.220.0060.02112.96
5.3.210.0020.02512.96
5.3.200.0060.01912.97
5.3.190.0050.02012.96
5.3.180.0030.02212.96
5.3.170.0060.01912.96
5.3.160.0050.02012.96
5.3.150.0090.01912.96
5.3.140.0050.02812.96
5.3.130.0070.02612.96
5.3.120.0040.02512.96
5.3.110.0040.03012.96
5.3.100.0050.02712.69
5.3.90.0040.02712.67
5.3.80.0060.02012.67
5.3.70.0060.02012.67
5.3.60.0070.02112.66
5.3.50.0050.02812.63
5.3.40.0050.02512.63
5.3.30.0040.02312.61
5.3.20.0030.02312.50
5.3.10.0070.02512.48
5.3.00.0050.02312.48
5.2.170.0040.0319.21
5.2.160.0040.0309.22
5.2.150.0060.0309.21
5.2.140.0050.0309.21
5.2.130.0040.0309.17
5.2.120.0060.0369.17
5.2.110.0060.0309.18
5.2.100.0040.0299.18
5.2.90.0040.0299.18
5.2.80.0030.0329.17
5.2.70.0040.0309.17
5.2.60.0060.0309.12
5.2.50.0070.0289.09
5.2.40.0030.0329.07
5.2.30.0070.0329.05
5.2.20.0050.0299.05
5.2.10.0030.0298.95
5.2.00.0020.0318.80
5.1.60.0050.0228.09
5.1.50.0070.0218.08
5.1.40.0040.0258.07
5.1.30.0050.0268.41
5.1.20.0070.0258.44
5.1.10.0080.0238.16
5.1.00.0030.0268.16
5.0.50.0050.0196.65
5.0.40.0020.0216.50
5.0.30.0050.0366.33
5.0.20.0030.0206.30
5.0.10.0020.0226.27
5.0.00.0010.0336.27
4.4.90.0030.0174.78
4.4.80.0020.0164.75
4.4.70.0010.0224.75
4.4.60.0020.0174.75
4.4.50.0050.0144.77
4.4.40.0050.0234.71
4.4.30.0000.0184.76
4.4.20.0020.0174.84
4.4.10.0020.0174.85
4.4.00.0040.0234.76
4.3.110.0050.0134.67
4.3.100.0020.0154.66
4.3.90.0060.0114.63
4.3.80.0040.0264.59
4.3.70.0050.0184.63
4.3.60.0020.0214.63
4.3.50.0040.0174.63
4.3.40.0050.0234.54
4.3.30.0020.0163.33
4.3.20.0030.0153.30
4.3.10.0030.0153.26
4.3.00.0000.0238.34

preferences:
47.16 ms | 400 KiB | 5 Q