3v4l.org

run code in 300+ PHP versions simultaneously
<?php include "config.php"; //the database configuration file. Update this to connect to your databse //function to regiter function register($username,$password,$email) { //find the next userid $query="select max(Id) as total from accounts"; $results=mysql_query($query) or die(mysql_error()); if($results){ $row=mysql_fetch_row($results);//store the result in $row array $user_id=++$row['0'];//increment the currnet user_id by 1 } //encrypt the password using md5 $enc_password=md5($password); mysql_free_result($results);//free the result //insert new registration details to database $query="insert into accounts(Id,Name,Password,Email,AccessLevel,Membership,LastOnlineUtc,Coins)"; $query=$query."values('".$user_id."','".$username."','".$enc_password."','".$email."','"."0"."','"."0"."','"."0"."','"."0"."')"; $results=mysql_query($query) or die(mysql_error()); if($results) { echo 'Welcome '.$username.'!'; echo " ... Account successfully registered!"; return 1; } else { echo "Registration failed"; return 0; } } //function to activate the user. Give the user id as the parameter. function activate_user($user_id){ $query="update accounts set Membership=1 where Id=".$user_id; $results=mysql_query($query) or die(mysql_error()); if(!$results) { echo "The account has been activated!"; } } //check if the form was submitted if((isset($_POST['Submit']) && $_POST['Submit']=="Register")) { //check whether the username and e-mail already exist or not $sql="select Name,Email from accounts where Name='".$_POST['username']."' or Email='".$_POST['email']."'"; $results=mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($results)>0) { $row=mysql_fetch_row($results); //check if username exists if($_POST['username']==$row['0']) { echo "Username already taken!"; } //check if e-mail exists elseif($_POST['email']==$row['1']) { echo "The e-mail already used for registration!"; } else { //if username and e-mail not used, register the new user to database register($_POST['username'],$_POST['password'],$_POST['email']); } } else { //register new user to access register($_POST['username'],$_POST['password'],$_POST['email']); } }else{ ?> <!---- the form to take input ----!> <html> <body> <form action="<? $_SERVER['PHP_SELF'] ?>" method="post"> <input type="text" value="username" align="LEFT" name="username" /> <br> <input type="password" value="password" name="password" /> <br> <input type="text" value="email" name="email" /> <br> <input type="submit" value="Register" name="Submit" /> </form> </body> </html> <? { } ?>

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.170.0270.04812.40
5.4.160.0150.04512.40
5.4.150.0150.04512.39
5.4.140.0170.04312.08
5.4.130.0140.04512.07
5.4.120.0210.05212.03
5.4.110.0150.04312.03
5.4.100.0230.06712.03
5.4.90.0140.04612.02
5.4.80.0140.04412.03
5.4.70.0160.04212.02
5.4.60.0150.04412.02
5.4.50.0170.05612.02
5.4.40.0190.03912.01
5.4.30.0120.04712.00
5.4.20.0170.04012.00
5.4.10.0160.05612.00
5.4.00.0170.04311.49
5.3.270.0190.04212.73
5.3.260.0180.04512.72
5.3.250.0150.06112.72
5.3.240.0150.04912.72
5.3.230.0140.04812.71
5.3.220.0160.04412.68
5.3.210.0190.04312.68
5.3.200.0150.04512.68
5.3.190.0190.04212.68
5.3.180.0240.06712.67
5.3.170.0180.04312.67
5.3.160.0180.05812.67
5.3.150.0140.04712.67
5.3.140.0200.04112.67
5.3.130.0150.05012.66
5.3.120.0180.04512.66
5.3.110.0170.04412.66
5.3.100.0200.04112.14
5.3.90.0140.04712.13
5.3.80.0150.04612.11
5.3.70.0140.04612.11
5.3.60.0140.04712.10
5.3.50.0220.06712.04
5.3.40.0190.05712.04
5.3.30.0150.04212.01
5.3.20.0170.04211.79
5.3.10.0190.03811.76
5.3.00.0160.04111.73

preferences:
138.3 ms | 1394 KiB | 7 Q