Friday, November 26, 2010

Function ereg() is deprecated

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.

Replace
ereg('\.([^\.]*$)', $this->file_src_name, $extension);
 
with
preg_match('/\.([^\.]*$)/', $this->file_src_name, $extension);
 
Notice that I wrapped the pattern (\.([^\.]*$)) around / /
which are RegExp delimiters. If you find yourself escaping / 
too much (for an URL for example), 
you might want to use the # delimiter instead. 

No comments:

Post a Comment