加拿大华人论坛 美国华人新闻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);
·加拿大新闻 加拿大19岁小伙高中毕业找了3年工作一无所获 有经验也没用
·加拿大新闻 加拿大和澳大利亚军舰过境台湾海峡:中国指责加拿大“挑衅”
·加拿大新闻 华人常用平台爆雷!加拿大四十年最大罢工潮掀起…
·加拿大新闻 布加迪发布首辆EB110America,LaMaisonPurSang认证
·加拿大新闻 BCGEU罢工升级!加薪谈不拢,BC全省公共服务第三天大瘫痪!
·中文新闻 澳大利亚两家最大的食品商店欠薪水不足的员工10亿美元
·中文新闻 奇怪的时刻梅根·泰(Megan Thee)种马通过墨西哥流浪乐队提供法