3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $username = ''; $password = ''; $host = ""; $dbname = ''; $options = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'); try { $db = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $username, $password, $options); } catch(PDOException $ex) { die("Failed to connect to the database: " . $ex->getMessage()); }
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Undefined class constant 'MYSQL_ATTR_INIT_COMMAND' in /in/3cBSo:7 Stack trace: #0 {main} thrown in /in/3cBSo on line 7
Process exited with code 255.
Output for 5.1.0 - 5.6.28
Fatal error: Undefined class constant 'MYSQL_ATTR_INIT_COMMAND' in /in/3cBSo on line 7
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Fatal error: Class 'PDO' not found in /in/3cBSo on line 7
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_DOUBLE_ARROW, expecting '(' in /in/3cBSo on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_DOUBLE_ARROW, expecting '(' in /in/3cBSo on line 7
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'('' in /in/3cBSo on line 7
Process exited with code 255.