Maison > Article > développement back-end > 修改一段代码
下面这段代码怎么改成http://localhost/GetAllPic.php? url=xxx
url=后面的网址就是要提交的网址不用点提交按钮
麻烦知道的大哥直接给代码,谢了
require_once 'DownImage.class.php';
?>
if($_POST['submit'] != NULL){
$url=$_POST['url'];
去掉上面的if判断,直接使用$url = $GET['url']
你自己判断下$GET['url']的合法性就OK了。
function modify_build_url($params = array(), $url = NULL) { //my_debug(current_url()); if (! $url) { $url = $_SERVER ['REQUEST_URI']; } $parts = parse_url ( $url ); if (! is_array ( $parts )) { $parts = array (); } if (! array_key_exists ( 'host', $parts )) { $parts ['host'] = $_SERVER ['HTTP_HOST']; } $gets = array (); if (array_key_exists ( 'query', $parts )) { $query = $parts ['query']; parse_str ( $query, $gets ); } if (! is_array ( $params )) { $params = array (); } if (! is_array ( $gets )) { $gets = array (); } foreach ( $params as $k => $v ) { $gets [$k] = $v; } $path = null; if (array_key_exists ( 'path', $parts )) { $path = $parts ['path']; } if (! $path) { $path = "/"; } $ret = sprintf ( "http://%s%s?%s", $parts ['host'], $path, http_build_query ( $gets ) ); return $ret; }<form method="POST" action="<?php echo modify_build_url()?>">....</form>