加拿大华人论坛 美国华人新闻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);
·加拿大新闻 收到这条短信别删!加拿大Rogers/Fido/Chatr用户有望领到一笔钱!
·加拿大新闻 别克GL8焕新登场,配炫酷大屏与舒适座椅,动力强劲
·加拿大新闻 胡锡进:美国最铁杆的盟友,现在却被美国百般羞辱
·加拿大新闻 TD预测:加拿大房市明年迎拐点房价全线看涨
·加拿大新闻 又一家电集团造车,打造移动客厅,夏普首款车有没有看头?
·中文新闻 旋风“阿尔弗雷德”过后,数千名昆士兰人在黑暗中度过了一周
·中文新闻 足球明星因对阵萨摩亚的疯狂尝试而走红








