使用Geoplugin旋转链接 [英] Rotate Links Using Geoplugin
本文介绍了使用Geoplugin旋转链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是geoplugin.class将CA用户重定向到特定链接。
现在,代码只允许我将用户重定向到1个网站。我想修改这段代码,这样我就可以将用户重定向到
link1.com
link2.com
link3。 com
有人对此有一个快速修改吗?
预先感谢您。
<?php
require_once('geoplugin.class.php');
$ geoplugin = new geoPlugin();
$ geoplugin-> locate();
$ geo_region = $ geoplugin->地区;
switch($ geo_region){
case'CA':
header('Location:http://www.link1.com');
出口;
默认://例外
标题('Location:http://www.everyoneelsegoeshere.com');
出口;
}
?>
解决方案
试试这个:
require_once('geoplugin.class.php');
$ geoplugin = new geoPlugin();
$ geoplugin-> locate();
$ geo_region = $ geoplugin->地区;
switch($ geo_region){
case'CA':
$ links = array('link1.com','link2.com , 'link3.com');
header('Location:http://'.$links [array_rand($ links)]);
出口;
default://例外
header('Location:http://www.everyoneelsegoeshere.com');
出口;
}
I'm geoplugin.class to redirect CA users to a specific link.
Right now the code only allows me to redirect the user to 1 website. I would like to modify this code so I can redirect the user to either
link1.com
link2.com
link3.com
Does anyone have a quick modification for this?
Thank you in advance.
<?php
require_once('geoplugin.class.php');
$geoplugin = new geoPlugin();
$geoplugin->locate();
$geo_region = $geoplugin->region;
switch($geo_region) {
case 'CA':
header('Location: http://www.link1.com');
exit;
default: // exceptions
header('Location: http://www.everyoneelsegoeshere.com');
exit;
}
?>
解决方案
Try This one:
require_once('geoplugin.class.php');
$geoplugin = new geoPlugin();
$geoplugin->locate();
$geo_region = $geoplugin->region;
switch($geo_region) {
case 'CA':
$links = array('link1.com','link2.com','link3.com');
header('Location: http://'.$links[array_rand($links)]);
exit;
default: // exceptions
header('Location: http://www.everyoneelsegoeshere.com');
exit;
}
这篇关于使用Geoplugin旋转链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文