3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Social network site where you can see a list of users and "follow" them. */ // setup the `Db` object: //require_once 'lib/db.php'; // setup the `Session` object: //require_once 'lib/session.php'; if (!Session::isLoggedIn()) { throw new Exception('You must be logged in to view this page'); } // display a user as html function displayUser ($user, $tag='div') { $full_name = $user->first_name . ' ' . $user->last_name; // get user's avatar from 3rd-party avatar service, based on which environment we're running in if (strpos($_SERVER['SERVER_NAME'], 'localhost') !== false) { $avatar_data = json_decode(file_get_contents('http://dev.avatars.com/user/' . $user->id)); } else { $avatar_data = json_decode(file_get_contents('http://www.avatars.com/user/' . $user->id)); } ?> <<?= $tag ?> class="user"> <a href="/users/<?= $user->id ?>"> <img src="<?= $avatar_data->url ?>"> <?= $full_name ?> </a> <a href="?follow=<?= $user->id ?>">Follow</a> </<?= $tag ?>> <?php } // check that a user ID is valid (must be a number) function validateUserId ($id) { if (!is_numeric($id)) { // log invalid user IDs to help us track down bugs. error_log("Invalid user id: {$id}"); return false; } return true; } // load the user's custom theme config $theme_filename = dirname(__FILE__) . 'themes/' . Session::getLoggedInUser()->theme_id . '.php'; if (file_exists($theme_filename)) { require $theme_filename; } // show all users if (isset($_GET['show-all'])) { echo '<ul>'; foreach (Db::getUsers() as $user) { displayUser($user, 'li'); } echo '</ul>'; } // show a single user else if (isset($_GET['id'])) { $id = $_GET['id']; if (!validateUserId($id)) throw new Exception('Please select a valid user ID'); $user = Db::getUserById($id); if (!$user) throw new Exception('Sorry, user not found'); displayUser($user); } // follow a user else if (isset($_GET['follow'])) { $id = $_GET['follow']; if (!validateUserId($id)) throw new Exception('Please select a valid user ID'); $user_to_follow = Db::getUserById($id); if (!$user_to_follow) throw new Exception('Sorry, user not found'); $current_user = Session::getLoggedInUser(); try { $current_user->follow($user_to_follow); } catch (Exception $e) { throw new Exception('Unable to follow at this time'); } // inform the user that they have a new follower. mail( $user_to_follow->email, 'You have a new follower!', "{$current_user->username} is now following you.", 'From: notifications@awesome-social-network.com' ); // also update the activity feed, so users can see what others are doing on the site. Db::updateActivityFeed(array( 'action' => 'follow', 'from' => $current_user->id, 'to' => $user_to_follow->id, 'timestamp' => time(), )); echo 'Followed! <a href="/">Return to home</a>'; } ?>

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.0.120.0070.00513.43
8.0.110.0040.00713.38
8.0.100.0000.01113.27
8.0.90.0070.00413.43
8.0.80.0110.00013.47
8.0.70.0040.00713.31
8.0.60.0080.00313.32
8.0.50.0110.00013.33
8.0.30.0110.00013.42
8.0.20.0070.00413.45
8.0.10.0090.00313.47
8.0.00.0000.00613.40
7.4.250.0060.00013.29
7.4.240.0130.00013.29
7.4.230.0000.00713.23
7.4.220.0030.00313.07
7.4.210.0030.00313.09
7.4.200.0050.00213.23
7.4.190.0070.00013.32
7.4.180.0030.00313.35
7.4.160.0000.00713.32
7.4.150.0030.00313.29
7.4.140.0040.00213.13
7.4.130.0050.00213.21
7.4.120.0040.00413.00
7.4.110.0030.00313.11
7.4.100.0000.00613.30
7.4.90.0050.00013.22
7.4.80.0040.00713.29
7.4.70.0090.00013.20
7.4.60.0090.00013.33
7.4.50.0080.00013.17
7.4.40.0090.00013.15
7.4.30.0040.00413.19
7.4.20.0040.00413.07
7.4.10.0030.00513.20
7.4.00.0080.00614.00
7.3.310.0030.00613.20
7.3.300.0040.00413.29
7.3.290.0050.00513.31
7.3.280.0060.00313.27
7.3.270.0050.00513.36
7.3.260.0080.00013.20
7.3.250.0080.00013.33
7.3.240.0000.00913.37
7.3.230.0090.00013.12
7.3.220.0000.01013.25
7.3.210.0050.00513.26
7.3.200.0050.00513.09
7.3.190.0080.00313.24
7.3.180.0090.00013.25
7.3.170.0070.00213.14
7.3.160.0060.00413.27
7.3.150.0080.00013.14
7.3.140.0080.00013.10
7.3.130.0040.00213.26
7.3.120.0050.00714.02
7.3.110.0030.00814.13
7.3.100.0090.00313.89
7.3.90.0050.00714.14
7.3.80.0050.00514.07
7.3.70.0050.00514.13
7.3.60.0080.00313.98
7.3.50.0060.00514.06
7.3.40.0050.00414.12
7.3.30.0090.00214.11
7.3.20.0040.00915.73
7.3.10.0100.00115.86
7.3.00.0090.00315.96
7.2.340.0040.00813.27
7.2.330.0050.00813.11
7.2.320.0100.00313.27
7.2.310.0070.00613.22
7.2.300.0060.00613.36
7.2.290.0090.00413.09
7.2.280.0130.00013.25
7.2.270.0080.00413.29
7.2.260.0090.00313.27
7.2.250.0100.00514.09
7.2.240.0060.01114.08
7.2.230.0010.01113.92
7.2.220.0100.00314.18
7.2.210.0080.00714.11
7.2.200.0070.00714.08
7.2.190.0070.00814.07
7.2.180.0090.00314.13
7.2.170.0060.00714.06
7.2.160.0070.00513.33
7.2.150.0100.00315.15
7.2.140.0060.00615.19
7.2.130.0150.00215.96
7.2.120.0100.00415.81
7.2.110.0110.00516.04
7.2.100.0140.00315.98
7.2.90.0030.01216.05
7.2.80.0120.00415.98
7.2.70.0120.00515.96
7.2.60.0080.00616.13
7.2.50.0100.00616.07
7.2.40.0060.00515.97
7.2.30.0080.00615.84
7.2.20.0140.00216.00
7.2.10.0090.00515.90
7.2.00.0070.00917.09
7.1.330.0070.00614.71
7.1.320.0080.00514.94
7.1.310.0060.00614.83
7.1.300.0070.00614.86
7.1.290.0070.00514.82
7.1.280.0060.00814.94
7.1.270.0080.00414.86
7.1.260.0060.00514.87
7.1.250.0060.00914.88
7.1.240.0060.00514.80
7.1.230.0090.00414.86
7.1.220.0100.00214.74
7.1.210.0030.01114.78
7.1.200.0110.00215.01
7.1.190.0120.00314.81
7.1.180.0100.00314.87
7.1.170.0050.00814.88
7.1.160.0090.00314.90
7.1.150.0070.01014.85
7.1.140.0110.00214.71
7.1.130.0120.00214.82
7.1.120.0080.00514.83
7.1.110.0060.00714.78
7.1.100.0060.00815.74
7.1.90.0030.01015.83
7.1.80.0030.01215.93
7.1.70.0060.00815.81
7.1.60.0110.00921.01
7.1.50.0130.00920.25
7.1.40.0140.00621.33
7.1.30.0130.00721.28
7.1.20.0150.00421.35
7.1.10.0060.00815.43
7.1.00.0050.02817.12
7.0.330.0120.00414.67
7.0.320.0120.00214.74
7.0.310.0100.00414.72
7.0.300.0090.00514.54
7.0.290.0100.00414.63
7.0.280.0070.00614.66
7.0.270.0090.00514.69
7.0.260.0100.00314.61
7.0.250.0100.00314.71
7.0.240.0090.00515.78
7.0.230.0060.00915.51
7.0.220.0100.00315.72
7.0.210.0100.00615.35
7.0.200.0090.00615.13
7.0.190.0100.00615.28
7.0.180.0070.00615.17
7.0.170.0070.00715.16
7.0.160.0060.00815.19
7.0.150.0070.00715.04
7.0.140.0100.00515.29
7.0.130.0090.00815.15
7.0.120.0110.00615.23
7.0.110.0090.00815.21
7.0.100.0180.01716.40
7.0.90.0160.02416.41
7.0.80.0140.02816.39
7.0.70.0180.02216.32
7.0.60.0140.02216.36
7.0.50.0140.01816.56
7.0.40.0080.01616.05
7.0.30.0030.02115.94
7.0.20.0060.02215.95
7.0.10.0070.02815.98
7.0.00.0090.01915.98
5.6.400.0060.00612.73
5.6.390.0070.00512.71
5.6.380.0080.00413.44
5.6.370.0100.00513.47
5.6.360.0080.00413.27
5.6.350.0070.00513.40
5.6.340.0020.01013.29
5.6.330.0090.00013.53
5.6.320.0050.00913.54
5.6.310.0050.00713.44
5.6.300.0100.02115.76
5.6.290.0130.02315.89
5.6.280.0090.03217.16
5.6.270.0080.02615.84
5.6.260.0160.02315.88
5.6.250.0090.03616.98
5.6.240.0130.03717.06
5.6.230.0080.04117.20
5.6.220.0110.03417.13
5.6.210.0080.03917.14
5.6.200.0080.04017.21
5.6.190.0080.03217.19
5.6.180.0070.03917.17
5.6.170.0100.04217.29
5.6.160.0080.04317.20
5.6.150.0100.03417.15
5.6.140.0070.03717.19
5.6.130.0070.03317.23
5.6.120.0090.03717.30
5.6.110.0070.03917.14
5.6.100.0070.03617.28
5.6.90.0050.03917.17
5.6.80.0080.04016.87
5.6.70.0080.03716.95
5.6.60.0080.03716.89
5.6.50.0070.03316.88
5.6.40.0080.02916.82
5.6.30.0080.03616.85
5.6.20.0110.03416.79
5.6.10.0090.03516.79
5.6.00.0060.03016.77
5.5.380.0060.03315.39
5.5.370.0060.02915.36
5.5.360.0060.04015.29
5.5.350.0070.03515.37
5.5.340.0080.03515.55
5.5.330.0070.04415.56
5.5.320.0070.03815.56
5.5.310.0070.03215.53
5.5.300.0080.04015.49
5.5.290.0050.04415.59
5.5.280.0080.02915.63
5.5.270.0100.04015.63
5.5.260.0040.04415.56
5.5.250.0070.03515.45
5.5.240.0100.03315.26
5.5.230.0060.04115.36
5.5.220.0070.03915.21
5.5.210.0090.03115.24
5.5.200.0080.02915.29
5.5.190.0120.03215.25
5.5.180.0090.03415.15
5.5.170.0090.00211.47
5.5.160.0080.03315.29
5.5.150.0060.03915.10
5.5.140.0110.03515.14
5.5.130.0070.02915.21
5.5.120.0100.03315.27
5.5.110.0090.03915.28
5.5.100.0050.03215.18
5.5.90.0130.02815.06
5.5.80.0060.03715.13
5.5.70.0060.03215.11
5.5.60.0070.02515.20
5.5.50.0080.02415.21
5.5.40.0060.02415.24
5.5.30.0050.02715.12
5.5.20.0070.02315.13
5.5.10.0080.02315.13
5.5.00.0110.02215.14
5.4.450.0060.04415.61
5.4.440.0090.02615.54
5.4.430.0070.04115.48
5.4.420.0080.03515.50
5.4.410.0080.02815.43
5.4.400.0090.03615.37
5.4.390.0140.02715.38
5.4.380.0080.03615.29
5.4.370.0080.03215.27
5.4.360.0070.04015.21
5.4.350.0080.03115.43
5.4.340.0070.03715.29
5.4.330.0060.00311.60
5.4.320.0080.02815.32
5.4.310.0090.03115.19
5.4.300.0090.02915.42
5.4.290.0070.03015.27
5.4.280.0090.03515.37
5.4.270.0090.03815.29
5.4.260.0070.02615.31
5.4.250.0090.03915.28
5.4.240.0100.03315.28
5.4.230.0070.02615.30
5.4.220.0040.02615.34
5.4.210.0070.02515.16
5.4.200.0090.02315.21
5.4.190.0070.02315.23
5.4.180.0070.02615.24
5.4.170.0060.02515.25
5.4.160.0050.02615.32
5.4.150.0060.02415.20
5.4.140.0030.02714.14
5.4.130.0070.02114.07
5.4.120.0080.02214.01
5.4.110.0090.02114.12
5.4.100.0070.02814.13
5.4.90.0040.03214.14
5.4.80.0090.02014.04
5.4.70.0080.02814.17
5.4.60.0060.03514.04
5.4.50.0080.03613.98
5.4.40.0090.03414.16
5.4.30.0070.02914.00
5.4.20.0060.02814.00
5.4.10.0030.02814.04
5.4.00.0050.02613.77
5.3.290.0070.02312.79
5.3.280.0070.01912.64
5.3.270.0060.02212.57
5.3.260.0050.02112.75
5.3.250.0070.02012.64
5.3.240.0020.02312.67
5.3.230.0040.02412.59
5.3.220.0040.02012.54
5.3.210.0060.02212.54
5.3.200.0070.02112.56
5.3.190.0070.02112.64
5.3.180.0080.02512.68
5.3.170.0020.02312.81
5.3.160.0070.02512.74
5.3.150.0030.02912.77
5.3.140.0110.02212.76
5.3.130.0070.02012.62
5.3.120.0030.02312.75
5.3.110.0080.02112.56
5.3.100.0040.02212.54
5.3.90.0030.02312.38
5.3.80.0060.01812.47
5.3.70.0050.01912.45
5.3.60.0070.01712.55
5.3.50.0090.01712.47
5.3.40.0050.02812.48
5.3.30.0150.01112.33
5.3.20.0060.02012.38
5.3.10.0050.02012.16
5.3.00.0030.02312.21
5.2.170.0050.01711.17
5.2.160.0040.01711.21
5.2.150.0040.01811.19
5.2.140.0040.01811.15
5.2.130.0050.01711.07
5.2.120.0040.01611.14
5.2.110.0040.01511.06
5.2.100.0080.01911.14
5.2.90.0040.01811.14
5.2.80.0050.01611.04
5.2.70.0050.01611.06
5.2.60.0100.01711.03
5.2.50.0030.01711.13
5.2.40.0030.01711.07
5.2.30.0070.01511.04
5.2.20.0060.01810.88
5.2.10.0060.01510.86
5.2.00.0040.01610.89
5.1.60.0060.01310.46
5.1.50.0040.01610.34
5.1.40.0060.01910.44
5.1.30.0090.01310.62
5.1.20.0080.01210.64
5.1.10.0070.01310.50
5.1.00.0050.01510.46
5.0.50.0040.0149.83
5.0.40.0060.0129.82
5.0.30.0060.0159.68
5.0.20.0050.0119.68
5.0.10.0040.0109.65
5.0.00.0010.0239.68
4.4.90.0020.0119.33
4.4.80.0020.0109.33
4.4.70.0020.0099.33
4.4.60.0020.0109.33
4.4.50.0020.0099.33
4.4.40.0040.0129.33
4.4.30.0030.0109.33
4.4.20.0020.0099.33
4.4.10.0020.0139.33
4.4.00.0010.0189.33
4.3.110.0040.0089.33
4.3.100.0030.0089.33
4.3.90.0030.0089.33
4.3.80.0040.0149.33
4.3.70.0030.0089.33
4.3.60.0010.0149.33
4.3.50.0050.0109.33
4.3.40.0030.0159.33
4.3.30.0040.0079.33
4.3.20.0010.0109.33
4.3.10.0020.0099.33
4.3.00.0030.0089.33

preferences:
45.99 ms | 401 KiB | 5 Q