ereg functions are deprecated
While looking at the PHP online reference for ereg, I noticed a huge deprecation notice:
Looks like all of the ereg functions (ereg_replace, etc.) are being removed in the new version of PHP. They are all deprecated in favor of the Perl-compatible functions:
Note: As of PHP 5.3.0, the regex extension is deprecated in favor of the PCRE extension. Calling this function will issue an E_DEPRECATED notice.
My codes are littered with ereg functions. Having to port my code over to use the PCRE extension is not going to be fun.
I found in many ereg_replace cases, you can simply surround the pattern with '/' when you convert to preg_replace. For example:
$line = ereg_replace ('\n', '', $line);
eregi_replace is for case-insensitive replacements. To substitute preg_replace for this function call, you'll have to use the 'i' modifier. For example:
$str = eregi_replace ("%7D", "}", $str);
For many cases where you are not searching for regular expression replacements, you can simply substitute str_replace instead. For example:
$str = ereg_replace (">", "%3E", $str);
If you use ereg to determine whether a string contains a regular expression, you can replace the ereg function with preg_match. For example:
$result = ereg ("\[MOVED\] ", $this->pageTitle)
Did your message disappear? Read the Forums FAQ.
Spam Control | * indicates required field
No TrackBacks yet. TrackBack can be used to link this thread to your weblog, or link your weblog to this thread. In addition, TrackBack can be used as a form of remote commenting. Rather than posting the comment directly on this thread, you can posts it on your own weblog. Then have your weblog sends a TrackBack ping to the TrackBack URL, so that your post would show up here.
Messages, files, and images copyright by respective owners.
20 Users Online
Copyright © 1996 - 2017. All Rights Reserved.