3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Entity extends PDO { public function __construct() { try { parent::__construct('mysql:host=localhost;dbname=X', 'db_user', 'db_pass'); parent::setAttributes(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch(PDOException $e) { die($e->getMessage()); }} } class DataSource { public static function simple_select($sql, array $values) { $smpt = (new Entity)->Prepare($sql); $smpt->execute($values); return $smpt->fetchAll(); } } class UniqueString { private $Secret; public function __construct($secret) { $this->Secret = $secret; } public function fetch() { return $this->Secret; } } class Generate { private static $Secret; private static $Sql = 'SELECT user_id FROM users WHERE salt = ?'; public static function randomString(int $len) { do { self::$Secret = mcrypt_create_iv($len, MCRYPT_DEV_URANDOM); } while (!empty(DataSource::simple_select(self::$Sql, [self::$Secret])['user_id'])); return new UniqueString(self::$Secret); } } echo Generate::randomString(16)->fetch();
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to undefined function mcrypt_create_iv() in /in/jPCSd:35 Stack trace: #0 /in/jPCSd(41): Generate::randomString(16) #1 {main} thrown in /in/jPCSd on line 35
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:
33.1 ms | 401 KiB | 8 Q