且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用PHP检查URL是否具有某些字符串

更新时间:2022-01-29 22:37:02

尝试类似的方法.第一行建立您的URL,其余行检查其是否包含单词"car".

Try something like this. The first row builds your URL and the rest check if it contains the word "car".

$url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];


if (strpos($url,'car') !== false) {
    echo 'Car exists.';
} else {
    echo 'No cars.';
}