3v4l.org

run code in 300+ PHP versions simultaneously
<?php session_start(); $pdo = new PDO('mysql:host=localhost;dbname=mydb', 'root', ''); if ($_SERVER['REQUEST_METHOD'] === 'POST') { $name = trim($_POST['name'] ?? ''); $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL); $message = trim($_POST['message'] ?? ''); if (empty($name) || !filter_var($email, FILTER_VALIDATE_EMAIL) || empty($message)) { $_SESSION['error'] = 'All fields required / invalid email'; } else { $stmt = $pdo->prepare( 'INSERT INTO contacts (name,email,message) VALUES (?,?,?)' ); $stmt->execute([$name, $email, $message]); $_SESSION['success'] = 'Message sent!'; } header('Location: contact.php'); exit; } ?>
Output for git.master_jit, git.master
Fatal error: Uncaught PDOException: could not find driver in /in/6d8tZ:3 Stack trace: #0 /in/6d8tZ(3): PDO->__construct('mysql:host=loca...', 'root', Object(SensitiveParameterValue)) #1 {main} thrown in /in/6d8tZ on line 3
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:
51.11 ms | 713 KiB | 4 Q