I have this warning, Deprecated: Function ereg_replace() is deprecated someone please help me.
ereg_replace:
ereg_replace('([^(folder)])/images/flash', '"/folder/images/flash', $echotemp);
to preg_replace:
I have this warning, Deprecated: Function ereg_replace() is deprecated someone please help me.
ereg_replace:
ereg_replace('([^(folder)])/images/flash', '"/folder/images/flash', $echotemp);
to preg_replace:
A deprecated method is a method that will in the future be dropped out of the language you're using. Unless you've got control on the language specifications and roadmap, you don't have much leverage.
You can still use the method, but it can disappear in a future update, and usually support about the method will just recommend switching to the new recommended ways of doing things.
I recommend using the replacement method for ereg_replace.
From: ereg_replace
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. See the list of differences for help on converting to PCRE.
.
Tip
preg_replace(), which uses a Perl-compatible regular expression syntax, is often a faster alternative to ereg_replace().
Read: PCRE regex syntax
And for your pattern:
When using the PCRE functions, it is required that the pattern is enclosed by delimiters. A delimiter can be any non-alphanumeric, non-backslash, non-whitespace character.
Often used delimiters are forward slashes (/), hash signs (#) and tildes (~).
If the delimiter needs to be matched inside the pattern it must be escaped using a backslash. If the delimiter appears often inside the pattern, it is a good idea to choose another delimiter in order to increase readability. So, your pattern should look like:
([^(folder)])/images/flash
[] that you have use in [^(folder)] is for specifying character-set and not a whole word. Its better to use simple patterns and not complicate a search pattern.
%^/folder/images/flash%
This is more simple.
I am using % as delimiter for readability.
Not using # because stackoverflow will treat it as a heading :P.