author:咔咔
preg_match函數是進行正規表達式的比對,成功傳回1,否則傳回0
參數說明:
參數 | 說明 |
pattern | 正規表達式 |
subject | 需要比對檢索的對象 |
matches | 可選,存儲比對結果的數組, $matches[0] 将包含與整個模式比對的文本,$matches[1] 将包含與第一個捕獲的括号中的子模式所比對的文本,以此類推 |
public function index()
{
if (preg_match("/php/i", "PHP is the web scripting language of choice.", $matches))
{
print "A match was found:" . $matches[0];
}
else
{
print "A match was not found.";
}
}
在這個正則裡邊有一個參數是i,這個在正規表達式裡邊是不區分大小寫的一個參數