2017-03-28 35 views
1

如何將以下eregi轉換爲preg_match?PHP 7 - 將eregi轉換爲preg_match

if (eregi("VERIFIED",$this->ipn_response)) { 
     // Valid IPN transaction.   
     $this->log_ipn_results(true);   
     return true;    
    } else {   
     // Invalid IPN transaction. Check the log for details. 
     $this->last_error = 'IPN Validation Failed.'; 
     $this->log_ipn_results(false);    
     return false;   
    } 
+0

你嘗試'如果(的preg_match( 「/通過/我」,$這個 - > ipn_response))' ? –

回答

0

eregi function執行

不區分大小寫的正則表達式匹配

因此,所有你需要的是

if (preg_match("/VERIFIED/i",$this->ipn_response)) { 
    // Do something if a match is found 
} 

其中/i是不區分大小寫的修改。

不過,如果你只是有一個硬編碼字符串如VERIFIED,你可以使用stripos

stripos($mystring, 'VERIFIED') 
+0

查看[使用stripos進行在線PHP演示](https://ideone.com/AL0Xcp)。 –