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, $phoneNumber) { $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, phone, name, email, encrypted_password, salt, created_at) VALUES('$uuid', '$phoneNumber', '$name', '$email', '$encrypted_password', '$salt', NOW())") or die(mysql_error()); // check for successful store if ($result) { // return user details return $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 Array**/ $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($user == true){ $result = mysql_query(" SELECT * FROM StudentCourses S_C, users S, UsfCourses C WHERE S.StudentID = '$user' AND S_C.CourseID = C.CourseID AND S_C.StudentID = S.StudentID")or die(mysql_error()); } else if($selectionKey =='CRN'){ $result = mysql_query("SELECT * FROM UsfCourses where $selectionKey = '$selectionValue'") or die(mysql_error()); } else { $result = mysql_query("SELECT * FROM UsfCourses where $selectionKey = '$selectionValue'") or die(mysql_error()); } if ($result->mysql_num_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; } return false; //course was not found } /** * 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) { $uid = mysql_insert_id(); // last inserted id $result = mysql_query("SELECT * FROM StudentCourses WHERE StudentClassID = $uid"); 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.1.70.0000.00716.67
7.1.60.0030.02119.13
7.1.50.0000.02016.73
7.1.00.0000.07722.44
7.0.200.0040.00416.61
7.0.100.0130.07720.00
7.0.90.0200.04020.16
7.0.80.0130.06320.03
7.0.70.0030.05020.03
7.0.60.0030.08020.10
7.0.50.0070.08020.36
7.0.40.0100.06320.13
7.0.30.0130.07319.96
7.0.20.0070.08720.18
7.0.10.0070.05020.07
7.0.00.0030.09020.04
5.6.280.0030.03321.21
5.6.250.0200.07020.66
5.6.240.0070.09020.56
5.6.230.0000.09020.68
5.6.220.0130.06020.66
5.6.210.0070.07720.67
5.6.200.0130.07720.99
5.6.190.0130.05721.13
5.6.180.0070.08320.99
5.6.170.0030.09021.06
5.6.160.0170.07721.07
5.6.150.0130.07321.09
5.6.140.0070.08020.98
5.6.130.0130.07720.98
5.6.120.0170.08321.00
5.6.110.0030.08721.08
5.6.100.0100.08021.09
5.6.90.0070.08021.07
5.6.80.0100.08020.39
5.6.70.0070.05020.48
5.6.60.0030.07720.55
5.6.50.0230.06720.46
5.6.40.0170.07320.44
5.6.30.0070.07720.42
5.6.20.0170.05320.43
5.6.10.0170.07720.52
5.6.00.0070.07720.44
5.5.380.0030.08720.48
5.5.370.0170.07320.40
5.5.360.0070.08720.39
5.5.350.0070.07720.52
5.5.340.0070.08720.95
5.5.330.0100.08020.91
5.5.320.0200.06320.88
5.5.310.0170.04021.00
5.5.300.0070.08320.95
5.5.290.0030.05720.99
5.5.280.0130.05720.98
5.5.270.0100.08020.87
5.5.260.0130.07720.81
5.5.250.0130.08020.80
5.5.240.0030.08320.20
5.5.230.0170.07320.32
5.5.220.0130.07320.34
5.5.210.0130.07020.20
5.5.200.0070.08720.15
5.5.190.0070.05020.20
5.5.180.0170.06720.30
5.5.160.0070.04320.27
5.5.150.0000.05320.32
5.5.140.0000.08320.22
5.5.130.0170.07320.21
5.5.120.0070.07320.24
5.5.110.0070.04720.15
5.5.100.0200.06720.23
5.5.90.0070.07320.16
5.5.80.0200.06720.10
5.5.70.0170.03720.09
5.5.60.0070.07320.20
5.5.50.0070.08320.19
5.5.40.0070.06720.13
5.5.30.0100.07320.11
5.5.20.0070.08020.10
5.5.10.0070.04720.14
5.5.00.0100.06720.10
5.4.450.0130.06019.49
5.4.440.0030.04719.27
5.4.430.0100.07719.23
5.4.420.0070.08019.27
5.4.410.0100.07019.24
5.4.400.0130.07718.85
5.4.390.0030.08319.14
5.4.380.0070.05719.16
5.4.370.0000.07019.12
5.4.360.0030.05319.05
5.4.350.0070.04318.85
5.4.340.0070.04719.04
5.4.320.0130.07319.09
5.4.310.0070.08019.03
5.4.300.0170.07019.22
5.4.290.0000.08018.90
5.4.280.0100.07719.03
5.4.270.0030.08018.84
5.4.260.0070.07018.89
5.4.250.0100.04319.23
5.4.240.0170.05719.20
5.4.230.0100.07019.09
5.4.220.0170.05718.94
5.4.210.0170.06319.12
5.4.200.0130.07019.11
5.4.190.0130.06319.13
5.4.180.0030.07719.21
5.4.170.0100.08019.13
5.4.160.0000.08019.14
5.4.150.0070.07719.16
5.4.140.0170.04716.28
5.4.130.0070.07716.33
5.4.120.0070.07316.41
5.4.110.0070.07716.41
5.4.100.0070.07316.45
5.4.90.0000.08016.41
5.4.80.0030.05716.40
5.4.70.0000.07316.32
5.4.60.0170.06016.39
5.4.50.0070.07316.45
5.4.40.0070.06716.29
5.4.30.0100.03316.56
5.4.20.0100.04316.34
5.4.10.0030.04316.53
5.4.00.0030.07715.88

preferences:
31.07 ms | 400 KiB | 5 Q