3v4l.org

run code in 300+ PHP versions simultaneously
<?php ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1); /** * Created in PhpStorm. * User: 750430 * Date: 04/03/2016 * Time: 20:52 */ include __DIR__.'/db_settings.php'; // try/catch to connect to the db and create the database using a prepared statement if it doesn't exist. try{ $pdo = new PDO("mysql:host' . HOST.'; charset='.CHARSET.';port='.POST.'", $user, $pass); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $pdo->prepare("CREATE DATABASE IF NOT EXISTS $db"); $stmt->execute(); $results["meta"]["feedback"] = "Database created."; return $results; } catch (PDOException $e) { echo 'Create DB failed: ' . $e->getMessage(); } try{ $stmt = $pdo->prepare("USE $db"); $stmt->execute(); $error = 'use db'; throw new Exception($error); } catch (PDOException $e) { echo 'DB use failed: ' . $e->getMessage(); } try{ $stmt = $pdo->query(DATABASE_INIT); $stmt->execute(); $error = 'create tables'; throw new Exception($error); } catch (PDOException $e) { echo 'Create tables failed: ' . $e->getMessage(); } echo ini_get('display_errors');
Output for git.master, git.master_jit, rfc.property-hooks
Warning: include(/in/db_settings.php): Failed to open stream: No such file or directory in /in/s24fs on line 11 Warning: include(): Failed opening '/in/db_settings.php' for inclusion (include_path='.:') in /in/s24fs on line 11 Warning: Undefined variable $user in /in/s24fs on line 15 Warning: Undefined variable $pass in /in/s24fs on line 15 Create DB failed: could not find driver Warning: Undefined variable $pdo in /in/s24fs on line 25 Fatal error: Uncaught Error: Call to a member function prepare() on null in /in/s24fs:25 Stack trace: #0 {main} thrown in /in/s24fs on line 25
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:
63.73 ms | 402 KiB | 8 Q