PDA

View Full Version : Function eregi() is deprecated help


z3r0
12-16-2016, 10:35 AM
Hi guys,

I'm just testing out php5.6 on my site and my error logs are filling with "Function eregi() is deprecated" messages that relate to this GARS plugin, from what I've been reading the eregi needs to be replaced with a preg_match, but I just can't get it right.


global $vbulletin;
if (is_object($vbulletin->gars))
{
$this->templatename = $vbulletin->gars->process_postbit();

if ($show['postcount_garstemp'])
{
$show['postcount'] = $show['postcount_garstemp'];
$post['postcount'] = $post['gar_postcount'];
}
if (!eregi('gars', $this->templatename))
{
$show['postcount_garstemp'] = $show['postcount'];
if ($post['postcount'] - $post['gar_postcount'] == 2)
{
$show['postcount'] = 0;
}
}
}


I'm sure it will be a simple fix for one of you guys.

Thanks

MarkFL
12-16-2016, 11:11 AM
Try:

if (preg_match('/gars/i', $this->templatename) !== 1)

edit:

It would be more efficient to use the stripos() function:

if (stripos($this->templatename, 'gars') === false)

z3r0
12-16-2016, 12:28 PM
Thanks, that seems to have done the trick :)