3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sql = <<<SQL getDataNlp:begin declare continue handler for sqlexception begin set returnCode = -1; set returnMsg = 'SQL Exception'; end; if useTransaction = 1 then start transaction; end if; set returnMsg = ''; set returnCode = 0; set @count = 0; set @orgName = orgName; set @orgId = ''; set @oprEmail = oprEmail; CreateOpr:BEGIN DECLARE idx INT DEFAULT 1; DECLARE v_orgName VARCHAR(128) DEFAULT ''; declare continue handler for sqlexception begin set returnCode = -1; set returnMsg = 'SQL Exception'; end; start transaction; set returnCode = 0; set returnMsg = ''; set @count = 0; set @oprName = oprName; select count(1) into @count from Opr where name = @oprName; if (@count > 0) then set returnCode = -1; set returnMsg = 'Opr with same oprName already exist'; rollback; leave CreateOpr; end if; END ;; SQL; $startWord = ':begin'; $endWord = 'sqlexception'; $maxLinesBetween = 4; preg_match_all('#.*' . preg_quote($startWord) . '.*(?:\R.*){0,' . $maxLinesBetween . '}.*' . preg_quote($endWord) . '.*?(?=\s*$)#im', $sql, $m); var_export($m[0]);
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
array ( 0 => 'getDataNlp:begin declare continue handler for sqlexception', )

preferences:
72.95 ms | 406 KiB | 5 Q