Why is ereg deprecated in PHP?
ereg
I had a lot of functions which used this, now they always give warning.
What is the alternative of this too?
Ereg is deprecated because it was replaced by the the PCRE extension. The reason(s) it was replaced and deprecated is answered in the below link, but to save you some time here is the copy and pasted answer:
Note: preg_match(), which uses a Perl-compatible regular expression syntax, is often a faster alternative to ereg().
PHP ereg vs. preg
One difference between the two is that ereg looks for the longest matching result while preg looks for the first result. Here is the list of differences between the two to help you in determining how best to go about updating your code: http://www.php.net/manual/en/reference.pcre.pattern.posix.php
It should be of note that PHP 6.0 has COMPLETELY removed ereg, so if you are eventually going to be moving your code to a newer server that may use PHP 6.0, the ereg function will no longer be available.
1.4m articles
1.4m replys
5 comments
57.0k users