url跳转代码
1.代码:
zuojiankuohaophpcn? $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怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号