3v4l.org

run code in 300+ PHP versions simultaneously
<?php function my_retarded_escape(string $str): string { $parts = explode("\00", $str); $parts = array_map([ 'SQLite3', 'escapeString' ], $parts); $str = implode("' || x'00' || '", $parts); return $str; } $db = new PDO('sqlite::memory:', '', '', array( PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION )); $db->exec(' CREATE TABLE foo(input TEXT);'); $text = "tro\x00lolo"; $db->query("INSERT INTO foo(`input`) VALUES ('" . SQLite3::escapeString($text) . "'),('" . my_retarded_escape($text) . "');"); var_dump($db->query("SELECT * FROM foo")->fetchAll(PDO::FETCH_ASSOC));
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { [0]=> array(1) { ["input"]=> string(3) "tro" } [1]=> array(1) { ["input"]=> string(8) "trololo" } }

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:
44.86 ms | 405 KiB | 5 Q