preg_match
$url = "https://www.baidu.com/api/users";
if (preg_match('/api/', $url)) {
return "包含";
} else {
return "不包含";
}
strpos
$url = "https://www.baidu.com/";
if (strpos($url, 'baidu') !== false) {
return "包含";
} else {
return "不包含";
}