0

我想根据他们重定向的页面更改 DIV 中的文本。

是否有任何if条件...或任何可以帮助我做到这一点的代码...搜索了所有互联网..但没有找到:(

如果来自 google.com 的用户减速器,我想向 googler 展示你好!如果他来自我的朋友网站,你好 xxx 读者。( Xxx = my friends blog name)。如果他是直接访客,您好访客。像这样....

希望你们能帮助我!谢谢!!

更新

在stackoverflow的其他问题中,我发现这个ode(ASP.NET)我需要一个类似的php。

在他写的这个 ASP 代码中,ENDS WITH(" ")但我想在那里写完整的 url。

protected void Page_Load(object sender, EventArgs e)
{
  string requestUrl = "";

  . . .

  if (requestUrl.ToString().EndsWith("Page1.aspx"))
    label.Text = "foo";
  else
    label.Text = "bar";
}

谢谢!

4

1 回答 1

1

$_SERVER['HTTP_REFERER']会做你需要的。

if (strstr($_SERVER['HTTP_REFERER'], 'facebook.com') !== false) {
    // Facebook brought me to this page.
}

else if (strstr($_SERVER['HTTP_REFERER'], 'google.com') !== false ) {
    // Google brought me to this page.
}

编辑

else if (strstr($_SERVER['HTTP_REFERER'], 'xxx.blogspot.com') !== false ) {
    // Your friend brought me to this page.
}
于 2013-05-17T04:06:13.867 回答