3v4l.org

run code in 300+ PHP versions simultaneously
<?php function display_table(){ global $mysqli; $phpself = $_SERVER["PHP_SELF"]; $user = $_SESSION['user']; echo<<<TABLE <html> <head> <title>Insert new record</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="description" content="" /> <meta name="keywords" content="" /> <!--[if lte IE 8]><script src="css/ie/html5shiv.js"></script><![endif]--> <script src="js/jquery.min.js"></script> <script src="js/jquery.dropotron.min.js"></script> <script src="js/skel.min.js"></script> <script src="js/skel-layers.min.js"></script> <script src="js/init.js"></script> <link rel="stylesheet" type="text/css" media="screen" href="css-table.css" /> <script type="text/javascript" src="js/jquery-1.2.6.min.js"></script> <script type="text/javascript" src="js/style-table.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript"> jQuery.expr[':'].contains = function(a,i,m){ return jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0; }; $(document).ready(function(){ $('input[name="search"]').keyup(function(){ var searchterm = $(this).val(); if(searchterm.length >2) { var match = $('tr.data-row:contains("' + searchterm + '")'); var nomatch = $('tr.data-row:not(:contains("' + searchterm + '"))'); match.addClass('selected'); nomatch.css("display", "none"); } else { $('tr.data-row').css("display", ""); $('tr.data-row').removeClass('selected'); } }); }); </script> <noscript> <link rel="stylesheet" href="css/skel.css" /> <link rel="stylesheet" href="css/style.css" /> <link rel="stylesheet" href="css/style-noscript.css" /> </noscript> <!--[if lte IE 8]><link rel="stylesheet" href="css/ie/v8.css" /><![endif]--> <!--[if lte IE 9]><link rel="stylesheet" href="css/ie/v9.css" /><![endif]--> </head> <body class="no-sidebar loading"> <!-- Header --> <header id="header"> <h1 id="logo"><a href="home.php">HOME <span>PAGE</span></a></h1> <nav id="nav"> <ul> <li class="current"><a href="home.php">Welcome, $user</a></li> <li class="submenu"> <a href="">Options</a> <ul> <li class="submenu"> <a href="">View Database</a> <ul> <li><a href="example.php">Prospects </a></li> <li><a href="clients.php">Clients </a></li> </ul> </li> <li><a href="excel.php">Download report</a></li> <li class="submenu"> <a href="">Add Record</a> <ul> <li><a href="import.php">Import file</a></li> </ul> </li> <li><a href="backup.php">Backup Database</a></li> <li><a href="restore.php">Import Database</a></li> </ul> </li> <li> <a href="index.php" class="button special">Sign Out </a></li> </ul> </nav> </header> <!-- Main --> <article id="main"> <header class="special container"> <span class="icon fa-mobile"></span> <h2>Backup Database Files</h2> <p></p> </header> <!-- One --> <section class="wrapper style4 container"> <form action="$phpself" method="post"> <center>Choose Type : &nbsp; <select name='type'> <option>prospects</option> <option>clients</option> </select><br/><br/><input type="submit" name="submit" value="Backup SQL Database Now"> </center><br/> </form> </section> <!-- Two --> </article> <!-- Footer --> <footer id="footer"> <ul class="icons"> <li><a href="#" class="icon circle fa-twitter"><span class="label">Twitter</span></a></li> <li><a href="#" class="icon circle fa-facebook"><span class="label">Facebook</span></a></li> <li><a href="#" class="icon circle fa-google-plus"><span class="label">Google+</span></a></li> <li><a href="#" class="icon circle fa-github"><span class="label">Github</span></a></li> <li><a href="#" class="icon circle fa-dribbble"><span class="label">Dribbble</span></a></li> </ul> <span class="copyright">&copy; Untitled. All rights reserved. Design: <a href="http://html5up.net">HTML5 UP</a>.</span> </footer> </body> </html> TABLE; } function badinput($msg){ echo <<<BADINPUT <html> <head> <title>Bad input</title> </head> <body> <h1>Error</h1> <p>Input could not be used because $msg.</p> </body> </html> BADINPUT; } // CLEAN QUERIES function clean($str) { if(@isset($str)){ $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } else{ return 'NULL'; } } // DATABASE BACKUP CREATING FUNCTION function backup_Database($hostName,$userName,$password,$DbName,$tables = '*') { // CONNECT TO THE DATABASE $con = mysql_connect($hostName,$userName,$password) or die(mysql_error()); mysql_select_db($DbName,$con) or die(mysql_error()); // GET ALL TABLES if($tables == '*') { $tables = array(); $result = mysql_query('SHOW TABLES'); while($row = mysql_fetch_row($result)) { $tables[] = $row[0]; } } else { $tables = is_array($tables) ? $tables : explode(',',$tables); } $return = 'SET FOREIGN_KEY_CHECKS=0;' . "\r\n"; $return.= 'SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";' . "\r\n"; $return.= 'SET AUTOCOMMIT=0;' . "\r\n"; $return.= 'START TRANSACTION;' . "\r\n"; foreach($tables as $table) { $result = mysql_query('SELECT * FROM '.$table) or die(mysql_error()); $num_fields = mysql_num_fields($result) or die(mysql_error()); $data.= 'DROP TABLE IF EXISTS '.$table.';'; $row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE '.$table)); $data.= "\n\n".$row2[1].";\n\n"; for ($i = 0; $i<$num_fields; $i++) { while($row = mysql_fetch_row($result)) { $data.= 'INSERT INTO '.$table.' VALUES('; for($x=0; $x<$num_fields; $x++) { $row[$x] = addslashes($row[$x]); //$row[$x] = ereg_replace("\n","\\n",$row[$x]); $row[$x] = clean($row[$x]);// CLEAN QUERIES if (isset($row[$x])) { $data.= '"'.$row[$x].'"' ; } else { $data.= '""'; } if ($x<($num_fields-1)) { $data.= ','; } } // end of the for loop 2 $data.= ");\n"; } // end of the while loop } // end of the for loop 1 $data.="\n\n\n"; } // end of the foreach*/ $return .= 'SET FOREIGN_KEY_CHECKS=1;' . "\r\n"; $return.= 'COMMIT;'; //SAVE THE BACKUP AS SQL FILE $handle = fopen($DbName.'-Database-Backup-'.$table.date('Y-m-d @ h-i-s').'.sql','w+'); fwrite($handle,$data); fclos($handle); /* gz format $gzdata = gzencode($data, 9); $handle = fopen($DbName.'-Database-Backup-'.date('Y-m-d @ h-i-s').'.sql.gz','w+'); fwrite($handle, $gzdata); fclose($handle);*/ if($data) return true; else return false; } // end of the function function addnewdata(){ global $mysqli; $utype = $_POST["type"]; $tables = $utype; $backup_response = backup_Database('ptjobstation.com','csci311','020809','user',$tables); if($backup_response) { echo <<<SUCCESSRESPONSE <html> <head> <title>New record inserted</title> </head> <body> <h1>Database Backup Successfully Created!</h1> <p>Please wait, link will be auto redirected</p> <script>setTimeout(function(){window.location.href='backup.php'},4000);</script> </body> </html> SUCCESSRESPONSE; } else { echo 'Errors in Database Backup Creating!'; } } session_cache_limiter ('private, must-revalidate'); $cache_limiter = session_cache_limiter(); // session_cache_expire(60); // 60 minutes session_start(); $user = $_SESSION['user']; function connectToDatabase(){ global $mysqli; $mysqli = new mysqli('ptjobstation.com','csci311','020809','user'); // Check for connection errors if(mysqli_connect_errno()){ $problem = mysqli_connect_error(); badinput($problem); exit; } } $method = $_SERVER["REQUEST_METHOD"]; if($method=="POST"){ addnewdata(); } else{ display_table(); } ?>

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.0120.00317.00
8.3.50.0070.01322.01
8.3.40.0120.00318.77
8.3.30.0090.00619.21
8.3.20.0080.00020.46
8.3.10.0060.00323.65
8.3.00.0000.00819.18
8.2.180.0090.00918.54
8.2.170.0120.00322.96
8.2.160.0140.00720.48
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0060.00326.16
8.2.120.0110.00420.79
8.2.110.0040.00422.24
8.2.100.0040.00718.09
8.2.90.0050.00319.18
8.2.80.0040.00417.97
8.2.70.0080.00017.75
8.2.60.0030.00518.16
8.2.50.0240.01418.07
8.2.40.0030.00520.01
8.2.30.0070.00018.29
8.2.20.0040.00417.93
8.2.10.0050.00218.32
8.2.00.0000.00818.00
8.1.280.0110.00725.92
8.1.270.0100.00022.19
8.1.260.0040.00426.35
8.1.250.0060.00328.09
8.1.240.0040.00422.29
8.1.230.0060.00619.35
8.1.220.0090.00017.91
8.1.210.0040.00418.77
8.1.200.0060.00317.48
8.1.190.0030.00617.22
8.1.180.0040.00418.10
8.1.170.0050.00318.76
8.1.160.0040.00422.06
8.1.150.0030.00618.76
8.1.140.0000.00817.55
8.1.130.0040.00417.89
8.1.120.0000.00717.57
8.1.110.0000.00717.52
8.1.100.0040.00417.44
8.1.90.0000.00717.53
8.1.80.0040.00417.50
8.1.70.0040.00417.54
8.1.60.0030.00617.67
8.1.50.0060.00317.52
8.1.40.0000.00817.50
8.1.30.0050.00317.80
8.1.20.0040.00417.71
8.1.10.0000.00817.62
8.1.00.0000.00817.56
8.0.300.0000.00818.77
8.0.290.0050.00317.30
8.0.280.0000.00718.53
8.0.270.0040.00417.34
8.0.260.0030.00317.27
8.0.250.0030.00317.07
8.0.240.0070.00316.98
8.0.230.0050.00216.95
8.0.220.0030.00317.01
8.0.210.0000.00716.91
8.0.200.0030.00316.96
8.0.190.0040.00417.00
8.0.180.0040.00417.12
8.0.170.0060.00317.14
8.0.160.0000.00716.97
8.0.150.0040.00416.98
8.0.140.0050.00217.04
8.0.130.0030.00313.38
8.0.120.0050.00316.89
8.0.110.0050.00317.02
8.0.100.0040.00417.07
8.0.90.0040.00417.15
8.0.80.0130.00317.05
8.0.70.0000.00717.02
8.0.60.0000.00716.87
8.0.50.0040.00417.05
8.0.30.0130.00717.23
8.0.20.0080.01117.40
8.0.10.0040.00417.22
8.0.00.0100.00816.77
7.4.330.0070.00015.00
7.4.320.0040.00416.68
7.4.300.0030.00316.49
7.4.290.0070.00016.44
7.4.280.0000.00816.65
7.4.270.0030.00516.54
7.4.260.0000.00816.56
7.4.250.0040.00416.47
7.4.240.0060.00116.59
7.4.230.0040.00416.57
7.4.220.0070.01316.64
7.4.210.0080.00816.66
7.4.200.0040.00416.51
7.4.190.0040.00416.70
7.4.160.0110.00716.82
7.4.150.0100.01117.40
7.4.140.0110.01117.86
7.4.130.0070.00916.67
7.4.120.0090.00916.69
7.4.110.0100.01316.63
7.4.100.0080.01216.80
7.4.90.0090.00916.66
7.4.80.0090.01519.39
7.4.70.0150.00616.62
7.4.60.0090.00916.55
7.4.50.0030.00616.55
7.4.40.0030.01316.55
7.4.30.0120.01216.68
7.4.00.0070.01014.87
7.3.330.0000.00613.30
7.3.320.0000.00513.51
7.3.310.0070.00016.53
7.3.300.0050.00316.50
7.3.290.0070.00716.49
7.3.280.0110.00916.48
7.3.270.0090.00917.40
7.3.260.0120.00616.71
7.3.250.0100.01116.56
7.3.240.0080.01016.54
7.3.230.0100.00716.50
7.3.210.0110.00716.49
7.3.200.0110.00719.39
7.3.190.0040.01416.42
7.3.180.0150.00616.42
7.3.170.0140.00716.61
7.3.160.0140.00316.64
7.3.120.0050.01215.12
7.3.110.0070.01015.01
7.3.100.0040.01114.73
7.3.90.0060.00914.72
7.3.80.0080.00515.07
7.3.70.0120.00615.05
7.3.60.0030.01314.96
7.3.50.0140.00014.86
7.3.40.0140.00014.96
7.3.30.0030.01014.97
7.3.20.0040.01116.54
7.3.10.0040.01216.82
7.3.00.0040.00816.76
7.2.330.0100.01016.59
7.2.320.0100.01016.95
7.2.310.0120.00916.51
7.2.300.0170.00316.85
7.2.290.0080.01116.52
7.2.250.0070.01315.32
7.2.240.0070.01414.97
7.2.230.0000.01515.21
7.2.220.0060.01015.08
7.2.210.0060.00915.27
7.2.200.0040.01515.16
7.2.190.0120.00315.05
7.2.180.0000.01215.02
7.2.170.0060.00915.17
7.2.60.0040.01116.61
7.2.00.0070.00719.37
7.1.330.0070.00715.89
7.1.320.0070.00715.61
7.1.310.0000.01615.86
7.1.300.0080.00815.65
7.1.290.0080.00815.70
7.1.280.0060.00615.62
7.1.270.0000.01115.79
7.1.260.0070.01015.78
7.1.200.0030.01215.93
7.1.100.0120.00918.01
7.1.70.0040.00816.86
7.1.60.0110.01119.46
7.1.50.0130.01317.02
7.1.00.0000.08022.54
7.0.200.0030.00716.61
7.0.140.0000.07722.00
7.0.80.0100.07719.94
7.0.70.0000.08719.95
7.0.60.0100.07020.05
7.0.50.0100.08720.23
7.0.40.0030.09320.08
7.0.30.0100.05020.15
7.0.20.0100.08320.05
7.0.10.0170.06320.03
7.0.00.0130.08019.95
5.6.280.0000.07720.95
5.6.230.0000.08720.63
5.6.220.0030.05320.68
5.6.210.0000.09020.77
5.6.200.0070.09021.07
5.6.190.0100.08021.05
5.6.180.0070.07721.11
5.6.170.0030.08721.06
5.6.160.0030.09021.18
5.6.150.0000.08721.18
5.6.140.0070.04021.06
5.6.130.0000.04721.21
5.6.120.0100.08020.97
5.6.110.0100.08321.09
5.6.100.0200.07321.13
5.6.90.0100.08020.98
5.6.80.0030.05320.48
5.6.70.0030.08020.49
5.6.60.0170.07320.51
5.6.50.0030.07720.50
5.6.40.0170.07320.41
5.6.30.0170.07020.36
5.6.20.0100.07320.33
5.6.10.0070.07020.34
5.6.00.0070.07720.46
5.5.370.0130.07320.38
5.5.360.0130.08020.42
5.5.350.0170.07320.49
5.5.340.0130.08020.86
5.5.330.0100.07320.91
5.5.320.0170.07720.94
5.5.310.0100.08020.86
5.5.300.0030.04320.77
5.5.290.0100.07720.86
5.5.280.0030.08720.76
5.5.270.0100.04320.93
5.5.260.0070.08020.75
5.5.250.0030.09020.60
5.5.240.0130.06720.22
5.5.230.0070.08320.30
5.5.220.0070.05320.31
5.5.210.0070.07020.31
5.5.200.0100.07020.16
5.5.190.0130.07720.15
5.5.180.0130.07020.31
5.5.160.0130.07020.24
5.5.150.0070.07720.11
5.5.140.0070.05720.14
5.5.130.0100.07320.24
5.5.120.0100.07320.21
5.5.110.0100.07720.26
5.5.100.0170.07320.01
5.5.90.0170.06720.13
5.5.80.0070.07719.98
5.5.70.0070.08020.20
5.5.60.0130.07020.09
5.5.50.0000.07320.03
5.5.40.0130.04020.09
5.5.30.0070.07720.08
5.5.20.0000.08020.18
5.5.10.0130.05320.11
5.5.00.0070.08020.07
5.4.450.0000.08019.48
5.4.440.0030.09019.20
5.4.430.0070.08019.22
5.4.420.0100.08019.45
5.4.410.0070.08319.43
5.4.400.0100.07719.05
5.4.390.0070.08019.21
5.4.380.0100.07319.04
5.4.370.0170.06718.96
5.4.360.0170.07319.23
5.4.350.0200.07319.05
5.4.340.0070.08019.04
5.4.320.0170.07019.21
5.4.310.0100.07018.95
5.4.300.0030.06319.11
5.4.290.0100.07719.18
5.4.280.0100.07719.03
5.4.270.0170.03719.02
5.4.260.0030.05319.14
5.4.250.0030.04019.04
5.4.240.0070.07719.16
5.4.230.0070.04018.90
5.4.220.0070.07719.18
5.4.210.0170.06018.86
5.4.200.0000.05018.87
5.4.190.0170.06319.11
5.4.180.0000.05018.84
5.4.170.0070.07319.11
5.4.160.0100.06719.03
5.4.150.0170.07019.16
5.4.140.0030.07316.44
5.4.130.0030.07316.45
5.4.120.0100.07016.47
5.4.110.0030.08016.51
5.4.100.0170.06316.39
5.4.90.0000.08016.45
5.4.80.0100.07016.38
5.4.70.0030.07716.52
5.4.60.0000.07016.51
5.4.50.0030.07016.48
5.4.40.0030.08016.45
5.4.30.0070.06316.37
5.4.20.0200.04016.38
5.4.10.0030.07716.46
5.4.00.0130.06315.88
5.3.290.0070.07314.64
5.3.280.0170.05714.75
5.3.270.0100.06714.58
5.3.260.0100.06714.71
5.3.250.0070.07014.71
5.3.240.0130.07314.74
5.3.230.0070.07714.78
5.3.220.0100.06014.58
5.3.210.0030.06014.55
5.3.200.0070.06714.73
5.3.190.0100.06714.73
5.3.180.0170.06714.62
5.3.170.0130.06314.76
5.3.160.0100.07314.57
5.3.150.0100.07014.72
5.3.140.0070.07714.62
5.3.130.0030.08014.54
5.3.120.0070.07714.55
5.3.110.0030.08314.65
5.3.100.0030.04314.14
5.3.90.0100.06714.04
5.3.80.0030.06014.04
5.3.70.0100.07714.20
5.3.60.0100.07013.95
5.3.50.0100.06714.02
5.3.40.0030.08014.01
5.3.30.0070.05314.09
5.3.20.0070.07313.86
5.3.10.0100.06313.62
5.3.00.0070.07313.61

preferences:
60.98 ms | 401 KiB | 5 Q