我正在用PHP写一个小网页。单击超链接时,超链接将被附加
function get_url($ff) {
$q = isset($_REQUEST['query']) ? $_REQUEST['query'] : NULL;
return "http" . (($_SERVER['SERVER_PORT']==443) ? "s://" : "://") . $_SERVER['HTTP_HOST'] .'?query=' .$q. '&bw' . '=' . $ff ;
}
<li><a href="<?php print get_url('exampl');?>">example</a></li>
输出网址
http://example.com/test/?query=search&bw=test.
点击下次我点击
http://example.com/test/?query=search&bw=test?query=search&bw=test.
答案 0 :(得分:1)
更改此
return "http" . (($_SERVER['SERVER_PORT']==443) ? "s://" : "://") . $_SERVER['HTTP_HOST'] .'?query=' .$q. '&bw' . '=' . $ff ;
到
return "http" . (($_SERVER['SERVER_PORT']==443) ? "s://" : "://") . $_SERVER['SERVER_NAME'] .'?query=' .$q. '&bw' . '=' . $ff ;