3v4l.org

run code in 300+ PHP versions simultaneously
<?php function FormatSql($query, array $params = []) { $patt = '~ ([\'"`]) # capture this quote character (?:\\\\.|(?!\1).)* # any escaped character, or # any character that isn\'t the captured one \1 # the captured quote again (*SKIP)(*FAIL) # ignore this | \?\?? # one or two question marks | ::?\w+ # word characters marked with one or two colons~x'; return preg_replace_callback($patt, function ($matches) use (&$params) { if(!isset($matches[1])) return $matches[0]; switch($matches[1]) { case '?': if(!$params) throw new \DomainException("Not enough params"); return '*snip*'; case '??': if(!$params) throw new \DomainException("Not enough params"); return '*snip*'; case ':': if(!array_key_exists($matches[2], $params)) throw new \DomainException("\"$matches[2]\" param not provided"); return '*snip*'; case '::': if(!array_key_exists($matches[2], $params)) throw new \DomainException("\"$matches[2]\" param not provided"); return '*snip*'; } throw new \Exception("Bad regex"); }, $query); } $bigStr = str_repeat('x', 443000); $bigQuery = "INSERT INTO `emr_doc_file` (`emr_doc_id`, `edf_file`, `edf_mimetype`, `edf_upload_date`) VALUES ('108', x'$bigStr', 'application/pdf', 1490978009)"; $result = FormatSql($bigQuery, []); if($result === null) { throw new \Exception("preg error: " . preg_last_error() . "\nsee: http://php.net/manual/en/pcre.constants.php#117743"); } echo substr($result,0,100).PHP_EOL;
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
Fatal error: Uncaught Exception: preg error: 6 see: http://php.net/manual/en/pcre.constants.php#117743 in /in/GdtmP:38 Stack trace: #0 {main} thrown in /in/GdtmP on line 38
Process exited with code 255.

preferences:
109.14 ms | 408 KiB | 5 Q