我正在使用USAePay的[糟糕的]PHP库连接到他们的网关,但是我遇到了以下错误:
这对应于以下行:已弃用:函数ereg_replace()已弃用,位于.../usaepay.php的第320行
$this->amount = ereg_replace("[^[:digit:].]", "", $this->amount);
所以,我想用preg_replace
来替换它。
这是我想的:
$this->amount = ereg_replace("/[^[\d].]/", "", $this->amount);
这与上面那个是否等价?
'/[^\d.]/'
更好(字符类内部的点无需转义) - ThiefMaster0-9
- 但在我看来,\d
更加“简洁”。由于你还想允许.
,所以\D
不起作用。 - ThiefMaster