3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (!defined('PHP_EOL')) { define('PHP_EOL', "\r\n"); } // generate the 32bit byte array (if you have the "openssl_random_pseudo_bytes" function available) if (function_exists('openssl_random_pseudo_bytes')) { $random_key = openssl_random_pseudo_bytes(32); } else { // this is the longer way to do it... $random_key = ''; for( $i = 0; $i < 64; $i++) { $random_key .= ((bool)rand(0, 1) ? chr(rand(65, 90)) : rand(0, 9)); } $random_key = hex2dec($random_key); } // this is it as hex print "Hex key: " . bin2hex($random_key) . PHP_EOL; print PHP_EOL; // this is the base64 string that you want to save print "Save this string: " . base64_encode($random_key) . PHP_EOL;

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)
7.4.00.0170.00315.00
7.3.120.0100.00715.07
7.3.110.0100.01014.96
7.3.100.0130.00314.70
7.3.90.0060.00914.99
7.3.80.0030.01014.94
7.3.70.0100.00314.85
7.3.60.0080.00814.70
7.3.50.0130.00314.95
7.3.40.0040.01114.71
7.3.30.0090.00614.77
7.3.20.0070.00716.82
7.3.10.0030.01116.48
7.3.00.0080.00716.51
7.2.250.0080.01115.23
7.2.240.0080.01214.87
7.2.230.0000.01515.20
7.2.220.0030.01015.04
7.2.210.0030.01315.18
7.2.200.0030.00715.16
7.2.190.0110.00014.93
7.2.180.0000.01014.81
7.2.170.0150.00014.81
7.2.130.0000.01417.00
7.2.120.0070.00716.68
7.2.110.0030.00716.96
7.2.100.0060.00916.89
7.2.90.0100.00616.93
7.2.80.0080.00616.98
7.2.70.0050.00516.94
7.2.60.0070.00716.99
7.2.50.0080.00816.95
7.2.40.0030.01117.04
7.2.30.0080.00316.71
7.2.20.0000.01716.99
7.2.10.0030.01016.75
7.2.00.0060.00718.16
7.1.330.0040.01115.86
7.1.320.0030.00915.80
7.1.310.0100.00315.84
7.1.300.0100.00615.86
7.1.290.0060.00615.84
7.1.280.0090.00615.74
7.1.270.0070.00715.91
7.1.260.0060.00316.00
7.1.250.0100.00315.84
7.1.240.0040.01115.99
7.1.230.0060.00915.73
7.1.220.0040.01115.62
7.1.210.0030.01015.95
7.1.200.0000.01015.84
7.1.190.0030.01315.85
7.1.180.0030.01015.64
7.1.170.0040.01115.89
7.1.160.0090.00315.51
7.1.150.0040.01115.93
7.1.140.0100.00715.64
7.1.130.0000.01315.77
7.1.120.0060.00315.63
7.1.110.0070.00715.63
7.1.100.0070.00715.62
7.1.90.0040.01115.52
7.1.80.0040.01115.56
7.1.70.0070.00316.57
7.1.60.0060.01517.64
7.1.50.0070.01116.41
7.1.40.0040.00915.84
7.1.30.0040.00415.55
7.1.20.0060.00615.85
7.1.10.0030.01015.84
7.1.00.0050.03819.08
7.0.330.0000.01015.28
7.0.320.0080.00815.40
7.0.310.0030.01015.35
7.0.300.0040.01115.25
7.0.290.0030.01015.39
7.0.280.0120.00315.47
7.0.270.0000.01015.36
7.0.260.0000.01515.40
7.0.250.0000.00815.13
7.0.240.0030.00915.49
7.0.230.0000.01215.51
7.0.220.0060.00615.55
7.0.210.0030.00615.48
7.0.200.0060.00416.02
7.0.190.0030.00915.38
7.0.180.0060.00615.31
7.0.170.0030.00715.37
7.0.160.0070.00315.21
7.0.150.0060.00615.44
7.0.140.0080.03818.73
7.0.130.0000.01015.49
7.0.120.0050.04018.74
7.0.110.0070.00715.57
7.0.100.0060.00615.45
7.0.90.0090.00315.43
7.0.80.0070.00715.13
7.0.70.0070.00015.31
7.0.60.0030.03317.59
7.0.50.0060.04616.69
7.0.40.0120.03715.71
7.0.30.0100.03115.67
7.0.20.0020.02515.58
7.0.10.0050.02315.50
7.0.00.0050.02215.68
5.6.380.0100.00014.62
5.6.370.0040.01114.20
5.6.360.0100.00014.59
5.6.350.0070.00314.27
5.6.340.0070.00714.07
5.6.330.0040.00814.42
5.6.320.0000.01714.46
5.6.310.0080.00814.13
5.6.300.0030.01214.54
5.6.290.0070.00714.59
5.6.280.0070.03917.67
5.6.270.0130.00014.05
5.6.260.0000.01214.32
5.6.250.0090.00314.22
5.6.240.0070.00313.98
5.6.230.0060.00614.29
5.6.220.0060.00614.20
5.6.210.0110.04317.36
5.6.200.0080.04016.22
5.6.190.0080.03316.21
5.6.180.0100.03816.41
5.6.170.0040.02416.25
5.6.160.0050.02216.14
5.6.150.0030.02516.38
5.6.140.0020.02616.23
5.6.130.0050.02316.25
5.6.120.0040.02416.33
5.6.110.0030.02516.22
5.6.100.0070.02016.17
5.6.90.0030.02416.21
5.6.80.0100.01716.03
5.6.70.0080.01815.84
5.6.60.0030.03015.83
5.6.50.0080.03615.93
5.6.40.0070.02515.87
5.6.30.0100.03515.90
5.6.20.0030.04415.82
5.6.10.0050.04315.95
5.6.00.0070.03815.94
5.5.380.0030.00910.99
5.5.370.0000.01211.05
5.5.360.0040.00711.15
5.5.350.0120.02215.65
5.5.340.0070.03914.57
5.5.330.0080.03314.48
5.5.320.0080.04314.60
5.5.310.0050.02314.51
5.5.300.0030.02214.54
5.5.290.0070.02014.50
5.5.280.0030.02514.47
5.5.270.0000.02514.48
5.5.260.0050.02214.48
5.5.250.0000.02514.38
5.5.240.0030.02214.24
5.5.230.0010.02414.12
5.5.220.0000.02514.24
5.5.210.0020.02314.18
5.5.200.0000.02614.09
5.5.190.0030.04414.08
5.5.180.0070.04014.12
5.5.170.0050.00511.12
5.5.160.0050.02414.26
5.5.150.0100.04014.32
5.5.140.0080.03814.11
5.5.130.0020.04214.24
5.5.120.0030.04214.09
5.5.110.0090.04014.23
5.5.100.0050.04014.05
5.5.90.0040.02314.14
5.5.80.0050.02213.96
5.5.70.0070.02114.00
5.5.60.0000.02713.98
5.5.50.0110.03814.15
5.5.40.0050.04413.92
5.5.30.0050.02414.11
5.5.20.0070.04014.18
5.5.10.0030.04314.02
5.5.00.0020.03214.12
5.4.450.0020.02315.23
5.4.440.0050.02015.10
5.4.430.0030.02314.99
5.4.420.0030.02315.27
5.4.410.0020.02215.28
5.4.400.0050.02115.01
5.4.390.0060.02015.06
5.4.380.0050.02014.98
5.4.370.0050.02014.97
5.4.360.0000.02314.90
5.4.350.0080.03914.87
5.4.340.0070.04315.08
5.4.330.0040.00810.72
5.4.320.0050.02114.99
5.4.310.0050.04015.15
5.4.300.0070.04315.08
5.4.290.0030.04614.93
5.4.280.0050.02714.98
5.4.270.0020.02414.96
5.4.260.0080.03815.08
5.4.250.0070.03314.82
5.4.240.0090.03515.01
5.4.230.0040.03514.93
5.4.220.0020.02715.17
5.4.210.0120.03314.89
5.4.200.0070.03014.96
5.4.190.0050.02314.98
5.4.180.0050.04215.15
5.4.170.0080.02515.05
5.4.160.0060.03514.82
5.4.150.0050.04315.09
5.4.140.0050.03513.71
5.4.130.0050.04313.69
5.4.120.0030.02513.67
5.4.110.0080.04013.73
5.4.100.0060.02313.60
5.4.90.0060.03713.49
5.4.80.0070.02013.58
5.4.70.0020.03513.63
5.4.60.0050.01813.77
5.4.50.0030.02813.55
5.4.40.0030.02513.55
5.4.30.0030.02913.59
5.4.20.0050.03313.72
5.4.10.0020.03513.62
5.4.00.0070.03313.27
5.3.290.0090.03712.62
5.3.280.0040.02312.49
5.3.270.0020.04312.55
5.3.260.0060.04112.50
5.3.250.0000.04312.46
5.3.240.0020.04312.56
5.3.230.0100.02312.47
5.3.220.0020.02612.39
5.3.210.0050.04312.38
5.3.200.0060.04012.47
5.3.190.0030.03812.57
5.3.180.0050.02012.69
5.3.170.0040.02312.55
5.3.160.0060.02812.54
5.3.150.0050.02112.54
5.3.140.0050.03612.37
5.3.130.0070.02712.49
5.3.120.0050.03312.57
5.3.110.0020.03012.47
5.3.100.0050.04312.19
5.3.90.0060.04012.29
5.3.80.0000.02912.20
5.3.70.0040.02412.11
5.3.60.0040.02012.19
5.3.50.0000.02412.12
5.3.40.0090.02612.20
5.3.30.0080.03212.01
5.3.20.0020.02811.93
5.3.10.0020.02711.96
5.3.00.0060.02311.88
5.2.170.0030.01710.29
5.2.160.0030.03610.39
5.2.150.0030.02210.33
5.2.140.0020.02610.39
5.2.130.0020.02210.33
5.2.120.0000.03710.29
5.2.110.0050.02510.37
5.2.100.0040.01510.35
5.2.90.0030.02710.39
5.2.80.0020.02210.36
5.2.70.0060.01610.36
5.2.60.0070.03310.35
5.2.50.0050.03410.33
5.2.40.0060.02110.28
5.2.30.0050.03510.31
5.2.20.0020.03510.29
5.2.10.0000.02110.23
5.2.00.0070.01310.21
5.1.60.0050.0129.85
5.1.50.0030.0229.85
5.1.40.0070.0189.92
5.1.30.0060.02610.09
5.1.20.0050.0209.95
5.1.10.0030.0309.90
5.1.00.0030.0309.78
5.0.50.0020.0159.08
5.0.40.0030.0249.08
5.0.30.0060.0309.05
5.0.20.0030.0188.95
5.0.10.0000.0168.91
5.0.00.0050.0258.93
4.4.90.0050.0108.55
4.4.80.0020.0158.55
4.4.70.0030.0188.55
4.4.60.0020.0178.55
4.4.50.0050.0088.55
4.4.40.0050.0278.55
4.4.30.0040.0178.55
4.4.20.0020.0228.55
4.4.10.0030.0218.55
4.4.00.0020.0218.55
4.3.110.0020.0188.55
4.3.100.0000.0158.55
4.3.90.0000.0148.55
4.3.80.0070.0258.55
4.3.70.0000.0128.55
4.3.60.0020.0128.55
4.3.50.0040.0208.55
4.3.40.0000.0168.55
4.3.30.0030.0108.55
4.3.20.0030.0108.55
4.3.10.0020.0158.55
4.3.00.0000.0148.55

preferences:
47.22 ms | 401 KiB | 5 Q