3v4l.org

run code in 300+ PHP versions simultaneously
<!DOCTYPE html> <?php global $db; $sqliteerror = null; try{ $db = new PDO('sqlite:/tmp/mysqlitedb.sqlite3'); } catch(Exception $e){ echo htmlentities($e->getMessage()); echo "<br><br><br>"; die('Error opening or creating new sqlite DB. Check write permissions for '.dirname(__FILE__)); } //Save if(isset($_POST['answer']) && trim($_POST['answer'])){ $sql = 'INSERT INTO survey (answer) VALUES (\''.$_POST['answer'].'\')'; $db->query($sql); } ?> <html> <head> <title></title> </head> <body> <fieldset> <legend>SURVEY: What is the best food?</legend> <form method="POST"> <label>Answer: <input type="text" name="answer"></label> <input type="submit"> </form> </fieldset> <fieldset> <legend>SURVEY: Previous Answers</legend> <?php $sql = 'SELECT COUNT(*) as x, `answer` FROM survey WHERE `answer` != \'\' GROUP BY `answer`'; foreach ($db->query($sql) as $row) { echo $row['x'] . "x ".$row['answer'].'<br>'; } ?> </fieldset> </body> </html>
Output for git.master_jit, git.master, rfc.property-hooks
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <fieldset> <legend>SURVEY: What is the best food?</legend> <form method="POST"> <label>Answer: <input type="text" name="answer"></label> <input type="submit"> </form> </fieldset> <fieldset> <legend>SURVEY: Previous Answers</legend> Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 1 no such table: survey in /in/6Gim1:38 Stack trace: #0 /in/6Gim1(38): PDO->query('SELECT COUNT(*)...') #1 {main} thrown in /in/6Gim1 on line 38
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
45.73 ms | 402 KiB | 8 Q