...

View Full Version : Problems with replacing depreciated function in my script



mister256
04-23-2012, 03:34 PM
I am having trouble understanding how to fix this error in my script as im not skilled in php very well any help is more than appreciated.

Here is the listed errors (2) in total

1) Deprecated: Function eregi() is deprecated in /home/socia125/public_html/profile.php on line 231

here is line 231 of my code


if (eregi($Match, $agent)) {

2)Deprecated: Function ereg_replace() is deprecated in /home/socia125/public_html/wi_class_files/autoMakeLinks.php on line 26

here us line 26 of my code


$newString = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\" target=\"_blank\">\\0</a>", $originalString);


any help is appreciated :confused:

Fou-Lu
04-23-2012, 04:32 PM
Its a deprecation warning. In the future, ereg functions will disappear completely.
You'll need to use preg instead as its PCRE not POSIX. I can't help you with the first one since there is no $Match available to modify, the but second one would be replaced with:


$newString = preg_replace('#[a-z]+://[^<>\s]+[a-z0-9]#i', '<a href="$0" target="_blank">$0</a>', $originalString);

Although the pattern could be cleaned up to actually match only a valid url.

mister256
04-23-2012, 05:53 PM
Its a deprecation warning. In the future, ereg functions will disappear completely.
You'll need to use preg instead as its PCRE not POSIX. I can't help you with the first one since there is no $Match available to modify, the but second one would be replaced with:


$newString = preg_replace('#[a-z]+://[^<>\s]+[a-z0-9]#i', '<a href="$0" target="_blank">$0</a>', $originalString);

Although the pattern could be cleaned up to actually match only a valid url.

thanks so much friend i appreciate it ;)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum