使用PHP或JS检查域扩展 [英] Check for domain extension with PHP or JS
本文介绍了使用PHP或JS检查域扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
首先我是php初学者,所以请尽可能具体. 基本上,我想要一个可以执行以下操作的php/javascript:
First of all I am a php beginner so please be as specific as possible. Basically I want a php/javascript that does the following:
如果域的扩展名为.de,则添加文本这是德国站点" 否则添加文本这不是德国站点"
if the domain has a .de extension then add the text "this is a german site" else add the text "this is not a german site"
如果您使用lang ="de-DE"而不是域扩展名也可以.
it's also ok if you do it with the lang="de-DE" instead of the domain extension.
推荐答案
To get the domain extension use php's pathinfo
$extension = pathinfo($_SERVER['SERVER_NAME'], PATHINFO_EXTENSION);
if($extension == "de")
{
echo "this is a german site";
}
另请参阅: $ _SERVER
这篇关于使用PHP或JS检查域扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文