3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DB_Functions { private $db; //put your code here // constructor function __construct() { require_once 'DB_Connect.php'; // connecting to database $this->db = new DB_Connect(); $this->db->connect(); } // destructor function __destruct() { } /** * Storing new user * returns user details */ public function storeUser($name, $email, $password) { $uuid = uniqid('', true); $hash = $this->hashSSHA($password); $encrypted_password = $hash["encrypted"]; // encrypted password $salt = $hash["salt"]; // salt $result = mysql_query("INSERT INTO users(unique_id, name, email, encrypted_password, salt, created_at) VALUES('$uuid', '$name', '$email', '$encrypted_password', '$salt', NOW())"); // check for successful store if ($result) { // get user details $uid = mysql_insert_id(); // last inserted id $result = mysql_query("SELECT * FROM users WHERE uid = $uid"); // return user details return mysql_fetch_array($result); } else { return false; } } /** * Get user by email and password */ public function getUserByEmailAndPassword($email, $password) { $result = mysql_query("SELECT * FROM users WHERE email = '$email'") or die(mysql_error()); // check for result $no_of_rows = mysql_num_rows($result); if ($no_of_rows > 0) { $result = mysql_fetch_array($result); $salt = $result['salt']; $encrypted_password = $result['encrypted_password']; $hash = $this->checkhashSSHA($salt, $password); // check for password equality if ($encrypted_password == $hash) { // user authentication details are correct return $result; } } else { // user not found return false; } } public function getCourses($user, $selectionKey, $selectionValue){ // Mysql select query $temp = array("CourseID"=>array(),"College" => array(), "Department"=>array(),"CRN" => array(), "SubjectCRS"=>array(),"Section" => array(), "Title"=>array(),"Building" => array(), "Room" => array(), "Instructor"=>array(),"Campus" => array(), "Time" =>array(), "Days" =>array()); $result = null; if($selectionKey =='CRN') $result = mysql_query("SELECT * FROM UsfCourses where '$selectionKey' = $selectionValue") or die(mysql_error()); if($selectionKey =='SubjectCRS') $result = mysql_query("SELECT * FROM UsfCourses where '$selectionKey' = '$selectionValue'") or die(mysql_error()); if($user == true){ $result = mysql_query(" SELECT C.* FROM StudentCourses S_C, users S, UsfCourses C WHERE S.StudentID = '$user' AND S_C.CourseID = C.CourseID"); } $no_of_rows = mysql_num_rows($result); if ($no_of_rows > 0) { while($row = mysql_fetch_array($result)){ array_push($temp["CourseID"], $row["CourseID"]); array_push($temp["College"], $row["College"]); array_push($temp["Department"], $row["Department"]); array_push($temp["CRN"], $row["CRN"]); array_push($temp["SubjectCRS"], $row["SubjectCRS"]); array_push($temp["Section"], $row["Section"]); array_push($temp["Title"], $row["Title"]); array_push($temp["Building"], $row["Building"]); array_push($temp["Room"], $row["Room"]); array_push($temp["Instructor"], $row["Instructor"]); array_push($temp["Campus"], $row["Campus"]); array_push($temp["Time"], $row["Time"]); array_push($temp["Days"], $row["Days"]); } return $temp; } //course was not found return false; } /** * Check user is existed or not */ public function isUserExisted($email) { $result = mysql_query("SELECT email from users WHERE email = '$email'"); $no_of_rows = mysql_num_rows($result); if ($no_of_rows > 0) { // user existed return true; } else { // user not existed return false; } } /** * Encrypting password * @param password * returns salt and encrypted password */ public function hashSSHA($password) { $salt = sha1(rand()); $salt = substr($salt, 0, 10); $encrypted = base64_encode(sha1($password . $salt, true) . $salt); $hash = array("salt" => $salt, "encrypted" => $encrypted); return $hash; } /** * Decrypting password * @param salt, password * returns hash string */ public function checkhashSSHA($salt, $password) { $hash = base64_encode(sha1($password . $salt, true) . $salt); return $hash; } public function storeCourse($StudentID, $CourseID){ $result = mysql_query("INSERT INTO StudentCourses(StudentID, CourseID) VALUES('$StudentID', '$CourseID')"); // check for successful store if ($result) { // get user details $uid = mysql_insert_id(); // last inserted id $result = mysql_query("SELECT * FROM StudentCourses WHERE StudentClassID = $uid"); // return user details return mysql_fetch_array($result); } else { return false; } } public function getFriendsByCourseIdAndStudentId($StudentID, $CourseID){ $temp = array("name"=>array(),"CourseID"=>array(),"College" => array(), "Department"=>array(),"CRN" => array(), "SubjectCRS"=>array(),"Section" => array(), "Title"=>array(),"Building" => array(), "Room" => array(), "Instructor"=>array(),"Campus" => array(), "Time" =>array(), "Days" =>array()); $result = mysql_query("SELECT U2.name, C.* FROM StudentCourses SC1, StudentCourses SC2, users U, Friends F, users U2, UsfCourses C WHERE SC1.StudentID = $StudentID AND F.StudentID = U.StudentID AND SC2.StudentID = F.FriendOfID AND SC1.CourseID = SC2.CourseID AND F.FriendOfID = U2.StudentID AND SC1.CourseID = $CourseID"); $no_of_rows = mysql_num_rows($result); if ($no_of_rows > 0) { while($row = mysql_fetch_array($result)){ array_push($temp["name"], $row["name"]); array_push($temp["CourseID"], $row["CourseID"]); array_push($temp["College"], $row["College"]); array_push($temp["Department"], $row["Department"]); array_push($temp["CRN"], $row["CRN"]); array_push($temp["SubjectCRS"], $row["SubjectCRS"]); array_push($temp["Section"], $row["Section"]); array_push($temp["Title"], $row["Title"]); array_push($temp["Building"], $row["Building"]); array_push($temp["Room"], $row["Room"]); array_push($temp["Instructor"], $row["Instructor"]); array_push($temp["Campus"], $row["Campus"]); array_push($temp["Time"], $row["Time"]); array_push($temp["Days"], $row["Days"]); } return $temp; } //course was not found return false; } } ?>

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.2.00.0030.01019.37
7.1.100.0030.01018.07
7.1.70.0030.00516.67
7.1.60.0070.02019.50
7.1.50.0000.01916.82
7.1.00.0000.07722.42
7.0.200.0140.00714.77
7.0.100.0070.04720.11
7.0.90.0100.05019.98
7.0.80.0130.07019.96
7.0.70.0100.06019.99
7.0.60.0070.08020.09
7.0.50.0100.03720.45
7.0.40.0170.07320.13
7.0.30.0170.04320.17
7.0.20.0070.07020.04
7.0.10.0070.08320.09
7.0.00.0130.07320.08
5.6.250.0070.04320.68
5.6.240.0030.04020.73
5.6.230.0070.05720.66
5.6.220.0070.08320.79
5.6.210.0000.09320.70
5.6.200.0130.04321.11
5.6.190.0030.08321.10
5.6.180.0100.08321.03
5.6.170.0030.09021.11
5.6.160.0030.05321.11
5.6.150.0200.06721.09
5.6.140.0100.08321.16
5.6.130.0070.08721.19
5.6.120.0170.06721.08
5.6.110.0100.09021.15
5.6.100.0030.09021.09
5.6.90.0070.05720.97
5.6.80.0070.07720.46
5.6.70.0070.07320.48
5.6.60.0030.04720.50
5.6.50.0100.08020.47
5.6.40.0030.08020.43
5.6.30.0100.04320.36
5.6.20.0100.05020.41
5.6.10.0100.08020.50
5.6.00.0100.07720.41
5.5.380.0070.03720.48
5.5.370.0030.04020.41
5.5.360.0100.07320.54
5.5.350.0000.09020.48
5.5.340.0070.08020.95
5.5.330.0130.06720.93
5.5.320.0070.05320.82
5.5.310.0230.06020.98
5.5.300.0130.08020.94
5.5.290.0030.05320.94
5.5.280.0170.06720.79
5.5.270.0100.08320.95
5.5.260.0030.08320.84
5.5.250.0100.08020.66
5.5.240.0030.08720.36
5.5.230.0030.07720.36
5.5.220.0030.07720.22
5.5.210.0070.07720.23
5.5.200.0100.06320.31
5.5.190.0130.07720.14
5.5.180.0100.08320.27
5.5.160.0070.04720.27
5.5.150.0200.07320.26
5.5.140.0000.08020.30
5.5.130.0130.07320.24
5.5.120.0030.08320.13
5.5.110.0030.07720.13
5.5.100.0170.05320.09
5.5.90.0130.07320.11
5.5.80.0070.08020.18
5.5.70.0030.08320.20
5.5.60.0130.07720.12
5.5.50.0070.08020.10
5.5.40.0130.07020.00
5.5.30.0130.07720.07
5.5.20.0070.07320.11
5.5.10.0070.08320.16
5.5.00.0030.08320.10
5.4.450.0030.09019.36
5.4.440.0200.06719.48
5.4.430.0070.07319.46
5.4.420.0100.07019.41
5.4.410.0070.08019.22
5.4.400.0030.08019.05
5.4.390.0170.06319.04
5.4.380.0070.08019.16
5.4.370.0030.08019.21
5.4.360.0070.07019.07
5.4.350.0070.06019.13
5.4.340.0100.07019.03
5.4.320.0070.03718.86
5.4.310.0070.08319.13
5.4.300.0100.08318.88
5.4.290.0070.03718.94
5.4.280.0030.08319.05
5.4.270.0130.07019.12
5.4.260.0170.06719.13
5.4.250.0070.07719.09
5.4.240.0070.07719.20
5.4.230.0130.07019.13
5.4.220.0100.07319.09
5.4.210.0030.04719.14
5.4.200.0100.07319.04
5.4.190.0130.07019.02
5.4.180.0100.07019.11
5.4.170.0130.07019.02
5.4.160.0100.07018.84
5.4.150.0070.07319.00
5.4.140.0070.06316.47
5.4.130.0070.05716.46
5.4.120.0030.05016.58
5.4.110.0000.07016.48
5.4.100.0070.07016.56
5.4.90.0070.06716.52
5.4.80.0000.07016.55
5.4.70.0100.06716.47
5.4.60.0070.06716.51
5.4.50.0030.05316.36
5.4.40.0070.05716.46
5.4.30.0070.07716.53
5.4.20.0070.07316.41
5.4.10.0000.08716.52
5.4.00.0070.05715.93

preferences:
25.92 ms | 400 KiB | 5 Q