我想知道如何創建一個PHP IF語句來檢測用戶是否正在加載/在某個URL上。在我的情況是:檢測用戶是否在子域上,然後使用PHP添加變量?
www.design.mywebsite.com
IF語句需要覆蓋整個子域,例如URL也必須被檢測:
www.design.mywebsite.com/filename.php
一旦IF語句建立,我想補充一個PHP變量。因此,它可能會幫助別人,我們稱之爲:
$myvariable = "Hey there! You're on my subdomain";
所以總結一下: 最後的代碼應該是這個樣子......
<?php
if //Code to detect subdomain// {
$myvariable = "Hey there! You're on my subdomain";
}
?>
這已經被問到:http://stackoverflow.com/questions/5292937/php-function-to-get-the-subdomain-of-a-url – Manuel 2012-04-16 09:49:17
你好dragon112。 我已經看過那個,是的,我知道它 - 但我有點困惑,我怎麼會把它變成一個PHP IF聲明。 – 2012-04-16 09:51:44
感謝評論如此迅速ogur :)。 我知道它需要一個parse_url(),但我不知道該從哪裏去。 – 2012-04-16 09:53:00