php – 在USAePay源代码中将ereg_replace转换为preg_replace
发布时间:2020-12-13 21:44:03 所属栏目:PHP教程 来源:网络整理
导读:我正在使用USAePay的[可怕] PHP库连接到他们的网关,但是我收到以下错误: Deprecated: Function ereg_replace() is deprecated in …/usaepay.php on line 320 这对应于以下行: $this-amount = ereg_replace("[^[:digit:].]","",$this-amount); 所以,我想用
我正在使用USAePay的[可怕]
PHP库连接到他们的网关,但是我收到以下错误:
这对应于以下行: $this->amount = ereg_replace("[^[:digit:].]","",$this->amount); 所以,我想用preg_replace切换它. $this->amount = ereg_replace("/[^[d].]/",$this->amount); 这相当于上面的那个吗? 解决方法
您希望从表示金额的字符串中删除任何非数字或非句点字符.你可以做:
$this->amount = preg_replace("/[^d.]/",$this->amount); 正则表达式使用: [ - Start of character class ^ - Negation d - any digit . - a literal perios ] - end of character class (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |