3v4l.org

run code in 300+ PHP versions simultaneously
<?php function escape(string $query) { return preg_replace_callback('/{(([^.}]+?)\.)?(.*?)}/', function ($matches) { $quoted = ''; // Quote table name. If there is an explicit database, quote it, too. if ($matches[2] !== '') { $quoted .= '`' . $matches[2] . '`.'; } // Quote the table name, keeping curly brackets so potential prefixes can // be added later. $quoted .= '`{' . $matches[3] . '}`'; return $quoted; }, $query); } var_dump(escape('SELECT * FROM system')); var_dump(escape('SELECT * FROM {system} ')); var_dump(escape('SELECT * FROM {db.system}')); var_dump(escape('SELECT * FROM db.system'));
Output for git.master, git.master_jit, rfc.property-hooks
string(20) "SELECT * FROM system" string(25) "SELECT * FROM `{system}` " string(29) "SELECT * FROM `db`.`{system}`" string(23) "SELECT * FROM db.system"

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