当前位置: 移动技术网 > IT编程>开发语言>PHP > php URL跳转代码 减少外链

php URL跳转代码 减少外链

2019年04月21日  | 移动技术网IT编程  | 我要评论
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>

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网