sabecs
asked on
PHP error - Deprecated: Function ereg_replace() is deprecated
Hi,
I am receiving the following error message and would like to know if I should replace all occurrences of ereg_replace with preg_replace in my code and do I need to change anything else?
Deprecated: Function ereg_replace() is deprecated in /home/mywebsite/public_htm l/admin/we bsite_sett ings.php on line 797
$imagesml = ereg_replace ( '.jpg', '_med.jpg', $row_view_tbl["image1"]);
$temps[$j] = ereg_replace ( '.jpg', '_sml.jpg', $temp[$j]);
Thanks in adavance for you feedback.
I am receiving the following error message and would like to know if I should replace all occurrences of ereg_replace with preg_replace in my code and do I need to change anything else?
Deprecated: Function ereg_replace() is deprecated in /home/mywebsite/public_htm
$imagesml = ereg_replace ( '.jpg', '_med.jpg', $row_view_tbl["image1"]);
$temps[$j] = ereg_replace ( '.jpg', '_sml.jpg', $temp[$j]);
Thanks in adavance for you feedback.
I am not recommending this as along-term strategy, but you can also turn off the Deprecated messages. That might be a good solution short term.
Add this to the top of your script:
Add this to the top of your script:
error_reporting(E_ALL ^ E_DEPRECATED);
Since this message is occurring as a byproduct of a PHP upgrade migration, you may want to know about other PHP upgrade issues. These articles cover a couple of the issues.
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_6630-Magic-Quotes-a-bad-idea-from-day-one.html
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_7317-Register-Globals-a-bad-idea-from-day-one.html
PHP also has migration guides on the web site. See the pages linked from this (left sidebar).
http://us.php.net/migration54
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_6630-Magic-Quotes-a-bad-idea-from-day-one.html
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_7317-Register-Globals-a-bad-idea-from-day-one.html
PHP also has migration guides on the web site. See the pages linked from this (left sidebar).
http://us.php.net/migration54
ASKER
Thanks for your feedback, I probably have about 100 occurrences throughout my website.
If I set error_reporting to hide the messages I am assuming that the ereg_replace will still work, is that correct and if so for how long?
If I set error_reporting to hide the messages I am assuming that the ereg_replace will still work, is that correct and if so for how long?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
100 occurrences doesn't take long to convert - feel free to post them.
ASKER
Thanks for your help, much appreciated.
I have about 100 occurrences but most are the same repeated throught the site so really I just have 5 similar ones which are shown below.
$imagesml = "/".ereg_replace ( '.jpg', '_swg.jpg', $row_view_photos1["image1" ]);
$image1 = ereg_replace ( '.jpg', '_swg.jpg', $image1);
$imagesml1 = ereg_replace ( '.jpg', '_sml.jpg', $row_view_tbl["image1"]);
$release = ereg_replace('^([[:digit:] ]+\.[[:dig it:]]+).*' , '\1', $parts[2]);
$release = ereg_replace('-.*', '', $parts[2]);
I have about 100 occurrences but most are the same repeated throught the site so really I just have 5 similar ones which are shown below.
$imagesml = "/".ereg_replace ( '.jpg', '_swg.jpg', $row_view_photos1["image1"
$image1 = ereg_replace ( '.jpg', '_swg.jpg', $image1);
$imagesml1 = ereg_replace ( '.jpg', '_sml.jpg', $row_view_tbl["image1"]);
$release = ereg_replace('^([[:digit:]
$release = ereg_replace('-.*', '', $parts[2]);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
$imagesml = ereg_replace ( '.jpg', '_med.jpg', $row_view_tbl["image1"]);
$imagesml = preg_replace ( '/\.jpg/', '_med.jpg', $row_view_tbl["image1"]); #Escaped the . to treat it as a literal period rather than a wilcard
$temps[$j] = ereg_replace ( '.jpg', '_sml.jpg', $temp[$j]);
$temps[$j] = preg_replace ( '/\.jpg/', '_sml.jpg', $temp[$j]); #Escaped the . to treat it as a literal period rather than a wilcard
Note the eregi_replace function is affected too.