How to check if page url has www in it or not with PHP?

前端 未结 6 798
悲&欢浪女
悲&欢浪女 2021-01-18 06:15

In PHP, how can I check if the current page has www in the url or not?

E.g if the user is on http://www.example.com/something , how can I find that there\'s www in t

6条回答
  •  自闭症患者
    2021-01-18 06:41

    There are so many ways to check whether www contains or not.

    one of the way is:

    if(strpos($_SERVER['HTTP_HOST'], `www`) !== false) {
        echo "WWW found";
    } else {
        echo "WWW not found";
    }
    

提交回复
热议问题