闲者博客 - 判断 https://bk1314.com/tag/%E5%88%A4%E6%96%AD/ zh-CN Sun, 06 Mar 2022 00:09:15 +0800 Sun, 06 Mar 2022 00:09:15 +0800 PHP循环判断关键词是否存在,如果存在就跳过 https://bk1314.com/59.html https://bk1314.com/59.html Sun, 06 Mar 2022 00:09:15 +0800 飞鱼 1.设置关键词数组,也可以利用mysql调用得到
$keyword_arr=['关键词1','关键词2','关键词3']

2.建立个子程序方便调用

function checKeyword($str='',$keyword_arr=[]){
    foreach ($keyword_arr as $keyword) {
        if (strstr($str, $keyword) != FALSE)return true;
//如果不需要区别大小写可以这么写
//              if (strstr(strtolower($str), strtolower($keyword)) != FALSE)return true;
    }
    return false;
}

3.调用方式演示

 $strtolowerbt="这里为内容查询这段是否有关键词包含";
if(checKeyword($strtolowerbt,$keyword_arr))
{
 continue;   
}
]]>
0 https://bk1314.com/59.html#comments https://bk1314.com/feed/tag/%E5%88%A4%E6%96%AD/
php 判断是否是https或者http 直接获取域名 https://bk1314.com/44.html https://bk1314.com/44.html Sat, 26 Feb 2022 10:11:19 +0800 飞鱼 //主动判断是否HTTPS function isHTTPS() { if (defined('HTTPS') && HTTPS) return true; if (!isset($_SERVER)) return FALSE; if (!isset($_SERVER['HTTPS'])) return FALSE; if ($_SERVER['HTTPS'] === 1) { //Apache return TRUE; } elseif ($_SERVER['HTTPS'] === 'on') { //IIS return TRUE; } elseif ($_SERVER['SERVER_PORT'] == 443) { //其他 return TRUE; } return FALSE; }
$codepay_config['host'] = (isHTTPS() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST']; //获取域名
]]>
0 https://bk1314.com/44.html#comments https://bk1314.com/feed/tag/%E5%88%A4%E6%96%AD/