3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SqlitePlatform { public static function udfSqrt($value) { return sqrt($value); } } $userDefinedFunctions = [ 'sqrt' => ['callback' => [SqlitePlatform::class, 'udfSqrt'], 'numArgs' => 1], ]; $dsn = "sqlite::memory:"; try { $pdo = new PDO($dsn); foreach ($userDefinedFunctions as $fn => $data) { $pdo->sqliteCreateFunction($fn, $data['callback'], $data['numArgs']); } \var_dump($pdo); } catch (PDOException $e) { \var_dump($e); }

preferences:
47.99 ms | 405 KiB | 5 Q