str_contains - kouji6309/SingleMVC GitHub Wiki

說明

檢查字串是否包含特定字串。
相同於 PHP 8 新函數 str_contains


原型

str_contains(string $haystack, string $needle) : bool

參數

  • haystack

    被搜尋的字串 。

  • needle

    尋找目標。若不是字串,將會被轉成字串。

回應

是否包含特定字串。


應用

檢查字串

if (str_contains('abcdefg', 'cde')) {
    output('text', '找到了');
} else {
    output('text', '找不到...');
}
⚠️ **GitHub.com Fallback** ⚠️