Warning when using preg_match()

Asked

Viewed 180 times

2

I had to migrate from PHP 5.2 to 5.3, so thousands of DEPRECATED messages started coming on my PHP system, but some are too complicated, follow the code :

if (!preg_match($SUBMENU.':', $sm)) {
    $sm = explode($SUBMENU.":\n", $sm);
    $sm = trim(preg_replace('/[^(<ul>)]<\/ul>.*/s', "\\1\t</ul>", $sm[1]));
    $sm = str_replace(array('{URL_IMAGENS}', '{URL_SITE}'), array(URL_IMAGENS, URL_SITE), $sm);
    $mainTpl->assign('SUBMENU', $sm, 'STATIC');
}

Then I get the mistake:

Warning: preg_match() [Function.preg-match]: Delimiter must not be alphanumeric or backslash in /home/sisv2/public_html/Adm/index.php on line 135

1 answer

2


When using regular expressions in PHP like preg_match() we must insert an extra delimiter into our Pattern. Your error is not to use any delimiter:

if (!preg_match('/' . $SUBMENU .':/', $sm)) 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.