3v4l.org

run code in 300+ PHP versions simultaneously
<?php $db = new PDO('sqlite::memory:'); // These are the only reasonable settings to ever use: $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Let's create a table: $db->exec("CREATE TABLE foo (username TEXT, pwhash TEXT, email TEXT)"); // Dummy rows: $db->exec("INSERT INTO foo(username, pwhash, email) VALUES ('scott', 'lolno', 'scott@paragonie.com')"); $db->exec("INSERT INTO foo(username, pwhash, email) VALUES ('robyn', 'fake!', 'robyn@paragonie.com')"); // Okay, now let's do a prepared statement, with an integer field $int = 12345; $stmt = $db->prepare("SELECT * FROM foo WHERE {$int} = ?"); $stmt->bindValue(1, $int, PDO::PARAM_INT); $stmt->execute(); var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
Output for 8.0.7, 8.1.23 - 8.1.30, 8.2.10 - 8.2.25, 8.3.0 - 8.3.4, 8.3.6 - 8.3.14, 8.4.1
array(2) { [0]=> array(3) { ["username"]=> string(5) "scott" ["pwhash"]=> string(5) "lolno" ["email"]=> string(19) "scott@paragonie.com" } [1]=> array(3) { ["username"]=> string(5) "robyn" ["pwhash"]=> string(5) "fake!" ["email"]=> string(19) "robyn@paragonie.com" } }
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 array(2) { [0]=> array(3) { ["username"]=> string(5) "scott" ["pwhash"]=> string(5) "lolno" ["email"]=> string(19) "scott@paragonie.com" } [1]=> array(3) { ["username"]=> string(5) "robyn" ["pwhash"]=> string(5) "fake!" ["email"]=> string(19) "robyn@paragonie.com" } }

preferences:
36.35 ms | 409 KiB | 5 Q