我大约 3 个月前才学会了 php,所以我希望我不会带你走上一条路,这是我会尝试的。
编辑:自从我学习 php 到现在已经大约 5 个月了。我在此编辑之前的上一个版本仅“构建”了 get to append(它可能不起作用)。
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);