我使用USAePay的[恐怖] PHP庫連接到自己的網關的preg_replace,但我發現了以下錯誤:轉換ereg_replace在USAePay源代碼
Deprecated: Function ereg_replace() is deprecated in .../usaepay.php on line 320
這相當於下面一行:
所以,我想與preg_replace
切換出來。
這裏就是我想:
$this->amount = ereg_replace("/[^[\d].]/", "", $this->amount);
這是等同於一個以上,或不?
'ereg'中的'[:digit:]'相當於'preg'中的簡單'\ d'嗎? – MegaHit
實際上,PCRE也支持[:digit:]字符類(參見[這個鏈接](http://ua.php.net/manual/en/regexp.reference.character-classes.php))。是的,他們都意味着同樣的事 – Exander
你應該使用正則表達式字符串的單引號。否則,你可能會意外地使用一些轉義序列而不是原始的'\ something'。 – ThiefMaster