我大约3个月前才学会了PHP,所以我希望我不会带领你走下一条路,这就是我会尝试的。
编辑:自从我学习了php以来已经有大约5个月了。我之前的版本在编辑之前只能“建立”获取追加(并且它可能不起作用)。
if (!isset($_GET['param'])) {$_GET['param'] = 'something';}
$var = '';
while ($other_gets = $_GET)
{
foreach ($other_gets as $key=>$value)
{
if ($key = 'something') {}//do nothing we want the other gets
else {$var .= '&'.$key.'='.$value;}
}
}
$get = '?'.$user_param.$other_gets;
的preg_replace您的扩展
$string = 'your webpage before output';
$patterns = array();
$patterns[0] = '/.html/';
$patterns[1] = '/.php/';
$patterns[2] = '/yoursite.com /';//with space
$replacements = array();
$replacements[0] = '.html'.$get;
$replacements[1] = '.php'.$get;
$replacements[2] = 'yoursite.com/index.php'.$get;
然后打印字符串
echo preg_replace($patterns, $replacements, $string);
我真的要问。为什么? – webnoob
如果您在提供值时使用默认值,那还不够吗? –
您当然可以使用cookie,但我没有看到其他解决方案的优势。但请注意,cookie值不会填充到$ _GET超全局变量中。 – arkascha