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); }
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
object(PDO)#1 (0) { }

preferences:
75.51 ms | 406 KiB | 5 Q