3v4l.org

run code in 200+ PHP versions simultaneously
<?php /** * Generate a random string, using a cryptographically secure * pseudorandom number generator (random_int) * * For PHP 7, random_int is a PHP core function * For PHP 5.x, depends on https://github.com/paragonie/random_compat * * @param int $length How many characters do we want? * @param string $keyspace A string of all possible characters * to select from * @return string */ function random_str( int $length = 64, string $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ): string { if ($length < 1) { throw new \RangeException("Length must be a positive integer"); } $pieces = []; $max = mb_strlen($keyspace, '8bit') - 1; for ($i = 0; $i < $length; ++$i) { $pieces []= $keyspace[random_int(0, $max)]; } return implode('', $pieces); } $a = random_str(32); $b = random_str(8, 'abcdefghijklmnopqrstuvwxyz'); $c = random_str(); var_dump($a, $b, $c);
based on 4rY4C

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.0rc40.0120.00414.81
7.4.0rc30.0120.00815.07
7.4.0rc20.0160.00914.77
7.4.0rc10.0150.00714.82
7.4.0beta40.0140.00814.82
7.4.0beta20.0100.00914.81
7.4.0beta10.0120.00714.82
7.4.0alpha30.0100.00914.92
7.4.0alpha20.0110.00815.03
7.4.0alpha10.0100.00815.00
7.3.100.0140.00814.74
7.3.90.0120.00814.72
7.3.80.0110.00914.79
7.3.70.0130.00814.72
7.3.60.0090.00814.77
7.3.50.0110.00914.75
7.3.40.0090.00714.74
7.3.30.0090.00814.74
7.3.20.0190.00815.30
7.3.10.0190.00815.27
7.3.00.0150.00815.30
7.2.230.0080.00815.02
7.2.220.0150.00914.92
7.2.210.0130.00914.90
7.2.200.0110.00814.92
7.2.190.0110.00814.92
7.2.180.0130.00914.94
7.2.170.0090.00914.91
7.2.160.0110.00814.93
7.2.150.0130.00815.48
7.2.140.0180.00815.48
7.2.130.0150.00915.58
7.2.120.0150.00915.50
7.2.110.0160.00915.47
7.2.100.0180.00815.50
7.2.90.0190.00715.53
7.2.80.0170.00815.56
7.2.70.0200.00915.52
7.2.60.0130.00915.54
7.2.50.0180.00815.52
7.2.40.0160.00915.49
7.2.30.0200.00915.56
7.2.20.0190.01015.50
7.2.10.0150.00915.57
7.2.00.0190.00715.53
7.1.320.0170.00814.46
7.1.310.0170.00814.50
7.1.300.0170.00814.42
7.1.290.0140.00814.38
7.1.280.0210.00814.40
7.1.270.0140.00714.42
7.1.260.0150.00914.46
7.1.250.0180.00914.48
7.1.240.0170.00714.61
7.1.230.0240.00814.53
7.1.220.0200.00814.60
7.1.210.0330.00714.51
7.1.200.0150.00914.57
7.1.190.0130.00914.54
7.1.180.0200.01014.57
7.1.170.0260.00714.59
7.1.160.0220.00814.41
7.1.150.0290.00814.46
7.1.140.0170.00914.46
7.1.130.0120.01214.42
7.1.120.0130.00914.58
7.1.110.0110.01014.58
7.1.100.0300.00814.58
7.1.90.0280.00714.63
7.1.80.0160.00914.58
7.1.70.0220.00814.63
7.1.60.0140.00914.62
7.1.50.0150.00814.53
7.1.40.0160.00714.58
7.1.30.0150.00714.54
7.1.20.0190.01114.50
7.1.10.0160.00814.58
7.1.00.0140.00914.54
7.0.330.0200.00814.15
7.0.320.0270.00614.17
7.0.310.0140.00914.11
7.0.300.0200.00914.17
7.0.290.0150.00814.11
7.0.280.0180.00814.18
7.0.270.0170.00814.17
7.0.260.0270.00714.13
7.0.250.0160.00714.24
7.0.240.0130.00814.19
7.0.230.0200.00914.24
7.0.220.0150.00814.29
7.0.210.0150.00814.20
7.0.200.0210.00714.17
7.0.190.0160.00814.20
7.0.180.0150.00714.18
7.0.170.0150.00714.21
7.0.160.0150.00814.10
7.0.150.0130.01014.18
7.0.140.0140.00914.19
7.0.130.0170.01014.11
7.0.120.0140.01014.18
7.0.110.0140.00814.13
7.0.100.0200.01014.12
7.0.90.0370.00714.15
7.0.80.0140.00714.13
7.0.70.0120.01014.20
7.0.60.0230.00714.17
7.0.50.0130.00914.27
7.0.40.0150.00714.21
7.0.30.0240.00914.24
7.0.20.0220.00714.14
7.0.10.0190.00814.29
7.0.00.0160.00814.14
5.6.400.0190.00913.96
5.6.390.0150.00714.04
5.6.380.0200.00814.03
5.6.370.0220.00814.03
5.6.360.0130.00914.06
5.6.350.0170.01014.05
5.6.340.0200.00914.07
5.6.330.0200.00714.04
5.6.320.0220.00914.04
5.6.310.0130.00914.09
5.6.300.0110.00914.12
5.6.290.0130.00814.05
5.6.280.0180.00914.11
5.6.270.0100.01114.03
5.6.260.0120.00813.99
5.6.250.0130.00813.97
5.6.240.0130.00914.07
5.6.230.0130.00914.05
5.6.220.0120.00914.08
5.6.210.0250.00813.95
5.6.200.0150.00714.06
5.6.190.0160.00914.01
5.6.180.0130.01014.07
5.6.170.0150.00714.04
5.6.160.0170.00814.08
5.6.150.0230.00914.05
5.6.140.0140.00914.04
5.6.130.0120.00914.01
5.6.120.0140.00813.96
5.6.110.0150.00613.99
5.6.100.0140.00814.05
5.6.90.0140.00713.97
5.6.80.0120.00813.91
5.6.70.0170.00813.92
5.6.60.0140.00913.91
5.6.50.0320.00914.00
5.6.40.0140.00913.84
5.6.30.0120.00913.94
5.6.20.0110.00813.93
5.6.10.0160.00713.94
5.6.00.0160.00913.90
5.5.380.0170.00713.95
5.5.370.0140.00614.05
5.5.360.0140.00813.89
5.5.350.0130.00813.94
5.5.340.0140.00614.00
5.5.330.0190.00813.86
5.5.320.0140.00614.11
5.5.310.0120.01014.00
5.5.300.0140.00714.01
5.5.290.0160.00813.96
5.5.280.0140.00713.88
5.5.270.0120.00913.95
5.5.260.0210.00914.01
5.5.250.0120.00913.91
5.5.240.0120.00913.84
5.5.230.0120.01113.92
5.5.220.0130.00913.86
5.5.210.0230.00913.86
5.5.200.0130.01013.90
5.5.190.0200.00813.89
5.5.180.0140.00613.93
5.5.170.0150.01113.85
5.5.160.0130.01113.88
5.5.150.0130.01013.92
5.5.140.0110.01113.88
5.5.130.0120.00813.87
5.5.120.0200.00913.82
5.5.110.0200.00613.90
5.5.100.0160.00713.78
5.5.90.0130.00813.87
5.5.80.0120.00813.91
5.5.70.0150.00713.77
5.5.60.0120.00813.88
5.5.50.0120.01013.85
5.5.40.0110.01113.93
5.5.30.0120.00913.84
5.5.20.0380.00813.87
5.5.10.0120.01013.79
5.5.00.0130.00813.86
5.4.450.0180.00711.70
5.4.440.0100.00511.70
5.4.430.0150.00511.71
5.4.420.0110.00411.63
5.4.410.0080.00711.71
5.4.400.0070.00711.70
5.4.390.0260.00611.64
5.4.380.0080.00811.66
5.4.370.0080.00711.67
5.4.360.0100.00611.65
5.4.350.0090.00611.67
5.4.340.0100.00511.68
5.4.330.0080.00711.64
5.4.320.0130.00611.67
5.4.310.0090.00811.69
5.4.300.0120.00611.67
5.4.290.0110.00611.71
5.4.280.0100.00511.69
5.4.270.0090.00611.67
5.4.260.0100.00511.69
5.4.250.0100.00511.67
5.4.240.0090.00611.67
5.4.230.0150.00511.71
5.4.220.0100.00611.67
5.4.210.0110.00411.65
5.4.200.0090.00611.69
5.4.190.0130.00711.64
5.4.180.0090.00711.65
5.4.170.0080.00711.66
5.4.160.0110.00511.70
5.4.150.0100.00611.61
5.4.140.0130.00611.73
5.4.130.0090.00711.67
5.4.120.0080.00711.66
5.4.110.0090.00711.76
5.4.100.0100.00511.67
5.4.90.0110.00811.68
5.4.80.0160.00611.69
5.4.70.0110.00611.69
5.4.60.0100.00611.67
5.4.50.0080.00711.65
5.4.40.0080.00711.65
5.4.30.0110.00511.67
5.4.20.0230.00611.67
5.4.10.0100.00511.67
5.4.00.0100.00511.66
5.3.290.0100.00611.56
5.3.280.0140.00511.49
5.3.270.0090.00411.53
5.3.260.0100.00511.53
5.3.250.0100.00411.54
5.3.240.0250.00611.50
5.3.230.0100.00511.49
5.3.220.0060.00911.47
5.3.210.0090.00511.51
5.3.200.0090.00611.51
5.3.190.0110.00611.52
5.3.180.0150.00511.56
5.3.170.0120.00611.57
5.3.160.0090.00611.58
5.3.150.0090.00611.55
5.3.140.0080.00711.55
5.3.130.0130.00611.55
5.3.120.0130.00611.56
5.3.110.0080.00511.53
5.3.100.0060.00811.57
5.3.90.0080.00511.56
5.3.80.0080.00611.50
5.3.70.0080.00511.50
5.3.60.0070.00511.53
5.3.50.0080.00511.53
5.3.40.0070.00611.48
5.3.30.0090.00511.51
5.3.20.0080.00511.48
5.3.10.0110.00711.45
5.3.00.0070.00711.45
5.2.170.0060.00611.24
5.2.160.0060.00411.22
5.2.150.0070.00411.24
5.2.140.0070.00511.21
5.2.130.0060.00611.19
5.2.120.0070.00511.20
5.2.110.0080.00511.21
5.2.100.0070.00511.23
5.2.90.0080.00511.19
5.2.80.0080.00311.23
5.2.70.0080.00511.21
5.2.60.0080.00311.17
5.2.50.0080.00511.24
5.2.40.0100.00411.22
5.2.30.0080.00611.20
5.2.20.0090.00311.16
5.2.10.0160.00511.14
5.2.00.0110.00411.12
5.1.60.0070.00511.02
5.1.50.0070.00411.00
5.1.40.0070.00311.04
5.1.30.0060.00511.05
5.1.20.0070.00411.00
5.1.10.0070.00411.02
5.1.00.0070.00311.01
5.0.50.0060.00310.90
5.0.40.0060.00210.90
5.0.30.0050.00310.90
5.0.20.0040.00410.92
5.0.10.0050.00410.92
5.0.00.0160.00310.92
4.4.90.0040.00310.90
4.4.80.0040.00310.90
4.4.70.0040.00410.90
4.4.60.0050.00310.90
4.4.50.0050.00210.90
4.4.40.0040.00410.90
4.4.30.0020.00510.90
4.4.20.0060.00210.90
4.4.10.0050.00310.90
4.4.00.0030.00410.90
4.3.110.0030.00410.90
4.3.100.0040.00210.90
4.3.90.0050.00310.92
4.3.80.0050.00210.92
4.3.70.0050.00210.92
4.3.60.0110.00310.92
4.3.50.0030.00310.92
4.3.40.0050.00210.92
4.3.30.0050.00210.92
4.3.20.0040.00310.92
4.3.10.0030.00310.92
4.3.00.0040.00210.92