3v4l.org

run code in 300+ PHP versions simultaneously
<?php //************************************************************* // place $req_status any where it will show the button/msg etc //************************************************************* //$user_email = email@example.com // get id by matching email address $result = mysql_query("SELECT id FROM tbluser WHERE email = '$user_email'"); if (!$result) { echo 'Could not run query'; } $row = mysql_fetch_assoc($result); $user_id = $row['id']; // id of the user //logged in. I assumed that you have the user id and profile id as follows. //$_SESSION['user_id'] = $user_id; if($_GET['fid']){ // ---------------------------------------------------- $friend_id = $_GET['fid']; // profile user id. // it shows "Friends" if user is friend. or "Add friend" or "Request pending" $query1="SELECT * FROM friends WHERE (user_id = '$user_id' AND friend_id = '$friend_id') OR (friend_id = '$friend_id' AND user_id = '$user_id')"; $result = mysql_query($query1); $row = mysql_num_rows($result); if ($row == 1) { // exist, whether it's active or not while($row = mysql_fetch_assoc($result)) { if ($row['status'] == 1) { echo "Friends"; } elseif ($row['status'] == 0) { if($row['user_id'] == $user_id){ $req_status = "Request pending"; //echo "Request pending"; } elseif($user_id == $row['friend_id']) { $uid = $row["user_id"]; $req_status = '<a href="add_friend.php?fid=$uid">Accept request</a> or <a href="ignore_request.php?fid=$uid">Ignore</a>'; } } else { if($row['user_id'] == $user_id){ $req_status = "Request pending"; //echo "Request pending"; } else { $req_status = '<a href="add_friend.php?fid='.$friend_id.'">Add Friend</a>'; //echo "<a href='add_friend.php?fid=".$friend_id."'>Add Friend</a>"; } } } } else { // if the relationship don't exist $req_status = '<a href="add_friend.php?fid=$friend_id">Add friend</a>'; //echo "<a href='add_friend.php?fid=".$friend_id."'>Add friend</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.3.60.0000.01516.75
8.3.50.0090.00917.53
8.3.40.0150.00318.70
8.3.30.0060.00918.77
8.3.20.0040.00418.77
8.3.10.0030.00520.46
8.3.00.0040.00419.51
8.2.180.0140.00316.38
8.2.170.0100.00722.96
8.2.160.0100.00320.93
8.2.150.0040.00424.18
8.2.140.0070.01024.66
8.2.130.0070.00026.16
8.2.120.0080.00020.80
8.2.110.0030.00721.04
8.2.100.0090.00317.91
8.2.90.0030.00720.86
8.2.80.0040.00418.04
8.2.70.0000.00817.50
8.2.60.0090.00017.80
8.2.50.0040.00418.07
8.2.40.0040.00418.16
8.2.30.0040.00418.00
8.2.20.0000.00817.65
8.2.10.0040.00417.61
8.2.00.0060.00317.70
8.1.280.0130.00625.92
8.1.270.0110.00724.66
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0030.00622.38
8.1.230.0080.00321.04
8.1.220.0040.00417.74
8.1.210.0000.00818.77
8.1.200.0060.00317.23
8.1.190.0000.00817.40
8.1.180.0040.00418.10
8.1.170.0040.00418.90
8.1.160.0040.00418.83
8.1.150.0040.00418.53
8.1.140.0000.00817.34
8.1.130.0060.00017.69
8.1.120.0000.01017.40
8.1.110.0000.00717.23
8.1.100.0050.00317.25
8.1.90.0000.00717.30
8.1.80.0040.00417.30
8.1.70.0000.00717.34
8.1.60.0000.00917.45
8.1.50.0020.00517.38
8.1.40.0030.00517.47
8.1.30.0040.00417.46
8.1.20.0000.00717.61
8.1.10.0040.00417.59
8.1.00.0000.00717.47
8.0.300.0040.00419.85
8.0.290.0000.00816.58
8.0.280.0030.00318.40
8.0.270.0000.00717.18
8.0.260.0070.00018.44
8.0.250.0000.00816.87
8.0.240.0030.00316.98
8.0.230.0030.00316.98
8.0.220.0050.00316.79
8.0.210.0030.00316.90
8.0.200.0000.00716.88
8.0.190.0070.00016.88
8.0.180.0000.00716.82
8.0.170.0050.00316.90
8.0.160.0040.00416.93
8.0.150.0080.00016.83
8.0.140.0060.00316.77
8.0.130.0030.00313.33
8.0.120.0000.00716.87
8.0.110.0040.00416.78
8.0.100.0040.00416.86
8.0.90.0000.00716.84
8.0.80.0060.00916.83
8.0.70.0040.00416.80
8.0.60.0000.00816.70
8.0.50.0000.00716.80
8.0.30.0100.01017.21
8.0.20.0130.00417.01
8.0.10.0040.00316.74
8.0.00.0070.01016.61
7.4.330.0040.00412.87
7.4.320.0000.00616.38
7.4.300.0060.00016.55
7.4.290.0000.00916.55
7.4.280.0030.00516.36
7.4.270.0000.00816.45
7.4.260.0050.00013.25
7.4.250.0000.00816.41
7.4.240.0070.00016.47
7.4.230.0000.00716.39
7.4.220.0130.00616.55
7.4.210.0070.00916.56
7.4.200.0040.00416.56
7.4.190.0080.00016.69
7.4.160.0090.00916.66
7.4.150.0160.00916.30
7.4.140.0110.00716.41
7.4.130.0110.00816.46
7.4.120.0100.00616.51
7.4.110.0080.01116.67
7.4.100.0090.01616.31
7.4.90.0100.00916.44
7.4.80.0100.00719.39
7.4.70.0040.01216.45
7.4.60.0130.00316.43
7.4.50.0040.00816.12
7.4.40.0000.01516.32
7.4.30.0090.01216.32
7.4.00.0070.01014.87
7.3.330.0000.00613.03
7.3.320.0030.00313.08
7.3.310.0000.00716.14
7.3.300.0030.00316.22
7.3.290.0040.01416.32
7.3.280.0060.01016.31
7.3.270.0080.00816.54
7.3.260.0200.00316.53
7.3.250.0130.00416.40
7.3.240.0110.00616.59
7.3.230.0080.00816.41
7.3.210.0100.00716.47
7.3.200.0090.01216.31
7.3.190.0090.01216.59
7.3.180.0000.01516.48
7.3.170.0090.00616.29
7.3.160.0210.00016.28
7.3.120.0030.01314.87
7.3.110.0100.00714.61
7.3.100.0100.00314.81
7.3.90.0070.00614.77
7.3.80.0000.01414.78
7.3.70.0000.01214.77
7.3.60.0070.01014.61
7.3.50.0110.00014.64
7.3.40.0100.00314.70
7.3.30.0080.00014.69
7.3.20.0070.00716.56
7.3.10.0040.00816.63
7.3.00.0040.01516.55
7.2.330.0090.00916.34
7.2.320.0100.00716.59
7.2.310.0040.02016.54
7.2.300.0130.00316.42
7.2.290.0080.00816.34
7.2.250.0040.00814.86
7.2.240.0100.01014.73
7.2.230.0040.01114.97
7.2.220.0120.00014.83
7.2.210.0050.00514.97
7.2.200.0100.00714.72
7.2.190.0000.01414.67
7.2.180.0000.01214.91
7.2.170.0090.00614.83
7.2.60.0080.00816.97
7.2.00.0080.00419.32
7.1.330.0070.00815.54
7.1.320.0100.00315.67
7.1.310.0000.01415.55
7.1.300.0070.01015.37
7.1.290.0100.00015.65
7.1.280.0090.00615.49
7.1.270.0100.00315.54
7.1.260.0000.01115.66
7.1.200.0000.01415.41
7.1.100.0000.01017.86
7.1.70.0000.01617.16
7.1.60.0130.01019.40
7.1.50.0030.00916.80
7.1.00.0030.05722.29
7.0.200.0000.00716.85
7.0.140.0030.07322.08
7.0.120.0000.07022.09
7.0.60.0100.07319.80
7.0.50.0030.04017.89
7.0.40.0170.07720.40
7.0.30.0300.04020.20
7.0.20.0300.06720.16
7.0.10.0000.04720.16
7.0.00.0130.07720.31
5.6.280.0070.07020.82
5.6.210.0070.05320.47
5.6.200.0000.05018.08
5.6.190.0100.08320.41
5.6.180.0270.05720.58
5.6.170.0330.04720.48
5.6.160.0000.04720.48
5.6.150.0070.08318.13
5.6.140.0070.07718.09
5.6.130.0130.07318.12
5.6.120.0100.08321.02
5.6.110.0100.05720.98
5.6.100.0000.08721.11
5.6.90.0030.04721.14
5.6.80.0000.04320.45
5.6.70.4570.03720.36
5.5.350.0130.08020.52
5.5.340.0030.04317.95
5.5.330.0030.05020.43
5.5.320.0170.04320.32
5.5.310.0270.07720.30
5.5.300.0030.08317.92
5.5.290.0100.07317.89
5.5.280.0130.07020.80
5.5.270.0230.07020.98
5.5.260.0070.06720.80
5.5.250.0000.04320.59
5.5.240.0230.08020.37
5.4.450.0030.08019.12
5.4.440.0100.04319.40
5.4.430.0000.05319.49
5.4.420.0070.07719.46
5.4.410.0100.06719.35
5.4.400.0070.03718.81
5.4.390.0030.04319.08
5.4.380.0030.04718.81
5.4.370.0030.05019.18
5.4.360.0130.07018.92
5.4.350.0030.05318.79
5.4.340.0100.07319.14
5.4.320.0000.04719.14
5.4.310.0000.04319.09
5.4.300.0030.03718.91
5.4.290.0000.04019.07
5.4.280.0030.04018.80
5.4.270.0070.07019.15
5.4.260.0030.03718.78
5.4.250.0100.03019.03
5.4.240.0030.03718.80
5.4.230.0000.04019.18
5.4.220.0030.04019.07
5.4.210.0070.03319.00
5.4.200.0000.04019.08
5.4.190.0000.04019.07
5.4.180.0030.03718.91
5.4.170.0030.03718.90
5.4.160.0070.03319.05
5.4.150.0030.03718.76
5.4.140.0070.03016.20
5.4.130.0000.03716.23
5.4.120.0000.03716.25
5.4.110.0070.03016.40
5.4.100.0030.03316.15
5.4.90.0070.03016.40
5.4.80.0030.03316.59
5.4.70.0070.03316.14
5.4.60.0030.03316.26
5.4.50.0030.03316.32
5.4.40.0030.03316.29
5.4.30.0030.03316.27
5.4.20.0000.05016.34
5.4.10.0000.04716.34
5.4.00.0030.03315.73
5.3.290.0000.04014.56
5.3.280.0070.04014.48
5.3.270.0030.04014.50
5.3.260.0070.03314.55
5.3.250.0000.04714.54
5.3.240.0000.04014.52
5.3.230.0030.03714.63
5.3.220.0000.03714.56
5.3.210.0000.04014.52
5.3.200.0030.03314.53
5.3.190.0170.03014.67
5.3.180.0030.04014.37
5.3.170.0000.03714.53
5.3.160.0030.03714.67
5.3.150.0030.04014.53
5.3.140.0000.03714.45
5.3.130.0070.03714.57
5.3.120.0000.08014.50
5.3.110.0070.03714.48
5.3.100.0070.07314.00
5.3.90.0000.04313.96
5.3.80.0070.04013.83
5.3.70.0030.06713.99
5.3.60.0000.04013.96
5.3.50.0070.04713.91
5.3.40.0030.07713.90
5.3.30.0100.05314.01
5.3.20.0070.03313.64
5.3.10.0030.04013.50
5.3.00.0100.06313.57
5.2.170.0030.04311.32
5.2.160.0070.03311.07
5.2.150.0070.06711.09
5.2.140.0130.02011.14
5.2.130.0000.05711.09
5.2.120.0030.03711.00
5.2.110.0100.05711.10
5.2.100.0030.04711.20
5.2.90.0030.05710.97
5.2.80.0030.06711.08
5.2.70.0000.03311.08
5.2.60.0000.03311.00
5.2.50.0070.03310.96
5.2.40.0100.02311.00
5.2.30.0100.02710.95
5.2.20.0030.05710.91
5.2.10.0100.03010.75
5.2.00.0000.06310.78
5.1.60.0030.0439.99
5.1.50.0070.03310.16
5.1.40.0070.04310.14
5.1.30.0030.05710.36
5.1.20.0030.05310.26
5.1.10.0030.05710.04
5.1.00.0000.0409.99
5.0.50.0100.0378.64
5.0.40.0000.0238.49
5.0.30.0070.0538.39
5.0.20.0030.0478.22
5.0.10.0030.0478.23
5.0.00.0030.0608.24
4.4.90.0030.0177.88
4.4.80.0030.0137.88
4.4.70.0000.0207.88
4.4.60.0000.0237.88
4.4.50.0030.0177.88
4.4.40.0000.0477.88
4.4.30.0000.0277.88
4.4.20.0000.0337.88
4.4.10.0000.0207.88
4.4.00.0030.0377.88
4.3.110.0030.0307.88
4.3.100.0030.0337.88
4.3.90.0030.0337.88
4.3.80.0000.0377.88
4.3.70.0030.0237.88
4.3.60.0030.0337.88
4.3.50.0030.0207.88
4.3.40.0000.0477.88
4.3.30.0000.0307.88
4.3.20.0000.0277.88
4.3.10.0030.0207.88
4.3.00.0000.0307.88

preferences:
42.99 ms | 401 KiB | 5 Q