[英]Replace old eregi function PHP
我因使用IN參數來修復此舊的PHP eregi功能時遇到問題。這是來自Matthieu MARY的驗證碼生成class_log.php的腳本
舊代碼:
$sMotif = "--$sIN ([a-zA-Z0-9]{3,4},)*([a-zA-Z0-9]{3,4}){1}";
if ((eregi("$sMotif ",$this->sParam))||(eregi("$sMotif$",$this->sParam))){
$this->aParam['bExtension'] = TRUE;
$this->aParam['aExtension'] = $this->_PARAM_get_extension($sIN);
$this->aParam['inExtension'] = ($sIN=='e');
$this->aParam['iParameters']++;
}
我嘗試這樣做,但不確定是否正確?
$sMotif = "/--$sIN ([a-zA-Z0-9]{3,4},)*([a-zA-Z0-9]{3,4}){1}/i";
if ((preg_match("$sMotif ",$this->sParam))||(eregi("$sMotif$",$this->sParam))){
$this->aParam['bExtension'] = TRUE;
$this->aParam['aExtension'] = $this->_PARAM_get_extension($sIN);
$this->aParam['inExtension'] = ($sIN=='e');
$this->aParam['iParameters']++;
}
TNX
這是我完成工作的方式:
$sMotif = "/--$sIN ([a-zA-Z0-9]{3,4},)*([a-zA-Z0-9]{3,4}) ?/";
if ( preg_match($sMotif,$this->sParam)) {
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.