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'] { $req_status = "<a href='add_friend.php?fid=".$row["user_id"]."'>Accept request</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)
5.4.160.0080.04212.39
5.4.150.0060.04112.38
5.4.140.0080.04312.07
5.4.130.0090.04112.05
5.4.120.0080.04212.02
5.4.110.0080.04012.02
5.4.100.0070.04412.02
5.4.90.0090.04512.02
5.4.80.0070.04412.01
5.4.70.0060.04712.01
5.4.60.0070.03712.01
5.4.50.0070.04012.01
5.4.40.0050.04012.00
5.4.30.0050.04211.99
5.4.20.0050.03911.99
5.4.10.0060.03811.99
5.4.00.0040.04211.48
5.3.260.0060.04312.72
5.3.250.0060.03812.72
5.3.240.0060.03812.72
5.3.230.0080.04112.71
5.3.220.0080.04312.68
5.3.210.0060.04012.68
5.3.200.0080.03812.68
5.3.190.0070.03912.68
5.3.180.0100.04312.67
5.3.170.0090.03912.67
5.3.160.0070.04112.67
5.3.150.0090.03912.67
5.3.140.0080.03912.66
5.3.130.0090.04212.66
5.3.120.0090.03912.66
5.3.110.0060.04112.66
5.3.100.0060.03712.12
5.3.90.0110.04112.09
5.3.80.0100.05012.08
5.3.70.0080.03912.08
5.3.60.0070.04312.06
5.3.50.0080.04112.00
5.3.40.0070.04312.00
5.3.30.0090.03711.95
5.3.20.0050.04011.73
5.3.10.0070.03611.69
5.3.00.0060.03811.68

preferences:
142.02 ms | 1394 KiB | 7 Q