加拿大华人论坛 美国华人新闻Fix `ereg is deprecated` errors in PHP 5.3
在加拿大
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);becomespreg_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.To migrate ereg_replace():$this->file_dst_name_body = ereg_replace('[^A-Za-z0-9_]', '', $this->file_dst_name_body);becomes$this->file_dst_name_body = preg_replace('/[^A-Za-z0-9_]/', '', $this->file_dst_name_body);Again, I just added delimiters to the pattern.If you are using eregi functions (which are the case-insensitive version of ereg), you’ll notice there’re no equivalent pregi functions. This is because this functionality is handled by RegExp modifiers.Basically, to make the pattern match characters in a case-insensitive way, append i after the delimiter:eregi('\.([^\.]*$)', $this->file_src_name, $extension);becomespreg_match('/\.([^\.]*$)/i', $this->file_src_name, $extension);
·加拿大新闻 央行本周预计降息!加拿大房主年省$1000!制造业回血 就业却雪
·加拿大新闻 澳媒:中国汽车超越澳大利亚质量标准
·加拿大新闻 科幻和激进的设计多数只属于纯电车?对,但为什么?
·加拿大新闻 多伦多27岁留学生不会法语,EE总分499也能上岸!职业是...
·加拿大新闻 奥迪E5 Sportback 豪华品牌的反击来了!|汽势
·汽车 新的(对我)的汽车建议
·汽车 2008大众高尔夫柴油油泄漏