3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php namespace 'CatsMakeTerriblePets'; function GimmeTehPDOz ($access, $host, $dbname, $port, $user, $pass) { // Set DSN $dsn = $access.':host=' . $host . ';dbname=' . $dbname. ';port=' . $port; // Set options $options = array( PDO::ATTR_PERSISTENT => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ); $dbh = false; $error = false; // Create a new PDO instanace try{ $dbh = new PDO($dsn, $user, $pass, $options); } // Catch any errors catch(PDOException $e){ $error = $e->getMessage(); } if (!$dbh) return $error; return $dbh; } $dbh = GimmeTehPDOz('', 'localhost', 'mysql', '3306', 'root', ''); var_dump($dbh);
based on WUXUS
Output for 5.4.0 - 5.4.35
Parse error: syntax error, unexpected ''CatsMakeTerriblePets'' (T_CONSTANT_ENCAPSED_STRING), expecting identifier (T_STRING) or \\ (T_NS_SEPARATOR) or '{' in /in/S8k4h on line 3
Process exited with code 255.
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting T_STRING or T_NS_SEPARATOR or '{' in /in/S8k4h on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /in/S8k4h on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /in/S8k4h on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/S8k4h on line 3
Process exited with code 255.