If you manage websites and have gone through or about to go update PHP to 5.3, you will almost certainly come accross the following error on your sites as a result. You may not even have know about the upgrade and suddenly start seeing these warnings all over your site:
ereg-is-deprecated in ..
If you upgraded to PHP 5.3, chances are high you’re going to run into a few warnings or deprecated function messages. An example is the ereg
family of functions, which are gone for good, as they were slower and felt less familiar than the alternative Perl-compatible preg
family.
To migrate ereg():
ereg('\.([^\.]*$)', $this->file_src_name, $extension);
becomes
preg_match('/\.([^\.]*$)/', $this->file_src_name, $extension);
Notice that the pattern (\.([^\.]*$)
) is wrapped with / /
, which are RegExp delimiters. If you find yourself escaping /
too much (for an URL for example), you might want to use the #
delimiter instead.
The full article "Fix `ereg is deprecated` errors in PHP 5.3" can be read on devthought.com
but the above snippets provided me enough to work with and clean up several clients sites after my hoster upgraded PHP.