3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Tell mysqli to throw an exception if an error occurs */ mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); $mysqli = new \mysqli("localhost", "my_user", "my_password", "world"); /* The table engine has to support transactions */ $mysqli->query("CREATE TABLE IF NOT EXISTS language ( Code text NOT NULL, Speakers int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"); /* Start transaction */ $mysqli->begin_transaction(); try { /* Insert some values */ $mysqli->query("INSERT INTO language(Code, Speakers) VALUES ('DE', 42000123)"); /* Try to insert invalid values */ $language_code = 'FR'; $native_speakers = 'Unknown'; $stmt = $mysqli->prepare('INSERT INTO language(Code, Speakers) VALUES (?,?)'); $stmt->bind_param('ss', $language_code, $native_speakers); $stmt->execute(); /* If code reaches this point without errors then commit the data in database */ $mysqli->commit(); } catch (\mysqli_sql_exception $exception) { $mysqli->rollback(); throw $exception; } /************************** * Procedural ***************************** / /* Tell mysqli to throw an exception if an error occurs */ mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); $mysqli = mysqli_connect("localhost", "my_user", "my_password", "world"); /* The table engine has to support transactions */ mysqli_query($mysqli, "CREATE TABLE IF NOT EXISTS language ( Code text NOT NULL, Speakers int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"); /* Start transaction */ mysqli_begin_transaction($mysqli); try { /* Insert some values */ mysqli_query($mysqli, "INSERT INTO language(Code, Speakers) VALUES ('DE', 42000123)"); /* Try to insert invalid values */ $language_code = 'FR'; $native_speakers = 'Unknown'; $stmt = mysqli_prepare($mysqli, 'INSERT INTO language(Code, Speakers) VALUES (?,?)'); mysqli_stmt_bind_param($stmt, 'ss', $language_code, $native_speakers); mysqli_stmt_execute($stmt); /* If code reaches this point without errors then commit the data in database */ mysqli_commit($mysqli); } catch (\mysqli_sql_exception $exception) { mysqli_rollback($mysqli); throw $exception; }
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to undefined function mysqli_report() in /in/9jIdh:4 Stack trace: #0 {main} thrown in /in/9jIdh on line 4
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:
55.14 ms | 401 KiB | 8 Q