php URL跳转代码 减少外链
php URL跳转代码 减少外链
发布时间:2016-12-29 来源:查字典编辑
摘要:URL跳转代码1.代码:如保存为aaa.php,可以实现aaa.php?url=www.baidu.com跳转到百度的效果.这个简单的调用了...

URL跳转代码

1.代码:

<? $url=$_GET["url"];header("Location:"."http://".$url);?> 如保存为aaa.php,可以实现aaa.php?url=www.baidu.com跳转到百度的效果.

这个简单的调用了默认的$_GET变量.以及php默认跳转Location:

2.实例升级:增加if循环

代码:

复制代码 代码如下:

<?

$url=$_GET["url"];

if (strlen($url >=3)){

header("Location:"."http://".$url);

}

?>

<html>

<head>

<title>URL转向页</title>

</head>

<body>

<form id="url" name="url" method="get" action="#">

<label>http://

<input name="url" type="text" value="" />

</label>

<input type="submit" name="Submit" value="提交" />

</form>

</body>

</html>

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新php教程学习
热门php教程学习
编程开发子分类