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)
5.6.150.0070.04018.13
5.6.140.0130.07718.16
5.6.130.0130.08318.29
5.6.120.0130.07321.14
5.6.110.0100.06720.98
5.6.100.0100.03321.00
5.6.90.0000.06720.99
5.6.80.0030.08020.56
5.6.70.4130.03720.30
5.5.300.0070.04018.07
5.5.290.0030.08717.98
5.5.280.0070.08720.79
5.5.270.0030.05020.88
5.5.260.0030.08320.89
5.5.250.0030.04020.79
5.5.240.0130.03320.29
5.4.450.0500.06019.48
5.4.440.0550.06219.45
5.4.430.0720.05219.43
5.4.420.0570.02319.57
5.4.410.0500.02819.42
5.4.400.0600.03219.24
5.4.390.0500.02819.14
5.4.380.0550.02319.05
5.4.370.0500.02818.98
5.4.360.0550.03519.10
5.4.350.0570.03819.09
5.4.340.0210.04714.41
5.4.320.0230.04314.71
5.4.310.0280.04314.64
5.4.300.0190.04914.73
5.4.290.0210.04714.78
5.4.280.0160.04414.65
5.4.270.0190.04114.71
5.4.260.0210.04814.70
5.4.250.0220.04414.60
5.4.240.0170.04014.66
5.4.230.0230.04514.57
5.4.220.0200.04114.66
5.4.210.0190.04114.71
5.4.200.0240.04914.65
5.4.190.0180.04114.65
5.4.180.0200.04214.69
5.4.170.0200.04014.74
5.4.160.0190.04114.73
5.4.150.0210.03814.55
5.4.140.0190.04513.52
5.4.130.0220.03813.59
5.4.120.0190.04213.50
5.4.110.0190.04113.57
5.4.100.0170.04213.60
5.4.90.0180.03813.57
5.4.80.0140.04313.47
5.4.70.0180.03813.57
5.4.60.0150.04113.55
5.4.50.0200.04013.42
5.4.40.0200.04113.52
5.4.30.0220.04313.51
5.4.20.0220.04413.43
5.4.10.0230.04313.53
5.4.00.0160.04213.02
5.3.290.0240.04913.38
5.3.280.0260.04613.34
5.3.270.0170.04713.36
5.3.260.0210.04813.36
5.3.250.0230.04313.32
5.3.240.0180.04613.34
5.3.230.0200.04113.31
5.3.220.0230.04813.32
5.3.210.0220.04213.28
5.3.200.0190.04613.33
5.3.190.0270.04313.27
5.3.180.0190.04413.30
5.3.170.0210.04413.28
5.3.160.0220.04013.31
5.3.150.0230.04013.32
5.3.140.0200.04513.29
5.3.130.0260.04413.26
5.3.120.0220.04313.26
5.3.110.0090.04313.26
5.3.100.0090.04312.75
5.3.90.0190.03612.84
5.3.80.0200.04112.75
5.3.70.0060.04112.78
5.3.60.0060.04512.81
5.3.50.0160.04212.66
5.3.40.0080.04012.73
5.3.30.0080.04012.59
5.3.20.0080.03812.40
5.3.10.0080.04712.36
5.3.00.0080.04312.45
5.2.170.0080.0349.89
5.2.160.0050.0369.86
5.2.150.0100.0339.87
5.2.140.0060.0349.88
5.2.130.0080.0359.83
5.2.120.0020.0409.92
5.2.110.0070.0339.85
5.2.100.0080.0309.86
5.2.90.0090.0359.89
5.2.80.0040.0359.80
5.2.70.0040.0399.81
5.2.60.0090.0389.87
5.2.50.0070.0359.74
5.2.40.0050.0329.70
5.2.30.0040.0409.68
5.2.20.0060.0339.72
5.2.10.0050.0319.58
5.2.00.0070.0329.42
5.1.60.0040.0278.72
5.1.50.0070.0268.80
5.1.40.0130.0308.67
5.1.30.0160.0389.05
5.1.20.0100.0279.15
5.1.10.0040.0398.84
5.1.00.0140.0308.77
5.0.50.0070.0217.27
5.0.40.0040.0247.16
5.0.30.0020.0366.97
5.0.20.0080.0216.92
5.0.10.0090.0216.90
5.0.00.0040.0366.92
4.4.90.0020.0205.25
4.4.80.0060.0165.23
4.4.70.0020.0195.24
4.4.60.0020.0215.26
4.4.50.0030.0215.27
4.4.40.0060.0275.24
4.4.30.0060.0225.27
4.4.20.0090.0175.35
4.4.10.0040.0205.36
4.4.00.0020.0285.30
4.3.110.0030.0175.24
4.3.100.0060.0145.24
4.3.90.0030.0175.22
4.3.80.0030.0295.19
4.3.70.0020.0185.22
4.3.60.0070.0155.22
4.3.50.0020.0195.22
4.3.40.0050.0265.17
4.3.30.0060.0184.34
4.3.20.0040.0164.32
4.3.10.0030.0164.29
4.3.00.0080.0226.87

preferences:
136.43 ms | 1394 KiB | 7 Q