Jump to content

Need help with changing eregi_replace after PHP upgrade


MockY

Recommended Posts

I got the following code from some tutorial long time ago and never really looked into why it works. The only thing I have changed is that links open up in a new window by adding a target property to the <a> tag. It basically makes potential links clickable once the user posts a message in a guestbook.

 

function href($text) {
   $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)','<a href="\\1" target="_blank">\\1</a>', $text);
   $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)','\\1<a href="http://\\2" target="_blank">\\2</a>', $text);
   $text = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})','<a href="mailto:\\1">\\1</a>', $text);
   return $text;
}

After a PHP upgrade, everywhere I use eregi_replace, notifications about eregi_replace (and it's siblings) are printed but still works. Since I obviously want to replace these functions with functions that will work even when PHP6 rolls out without disabling error printing in php.ini, getting some help in terms of altering them would be much appreciated.

 

So how would I change this function to work in similar way?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.