我尝试用变量替换递归回声。
但是我得到的结果不一样
这里的工作脚本:
if ( $currentpage <= 3 && $currentpage != "all" ) {
$a = 3;
echo '<a class="page bgcolor2" href="?pagenb=' . ($a-2) . '">' . ($a-2) . '</a>';
echo '<a class="page bgcolor2" href="?pagenb=' . ($a-1) . '">' . ($a-1) . '</a>';
echo '<a class="page bgcolor2" href="?pagenb=' . ($a) . '">' . ($a) . '</a>';
echo '<a class="page bgcolor2" href="?pagenb=' . ($a+1) . '">' . ($a+1) . '</a>';
echo '<a class="page bgcolor2" href="?pagenb=' . ($a+2) . '">' . ($a+2) . '</a>';
}
if ( $currentpage > 3 && $currentpage != "all" && $currentpage < $pages-2) {
$a = $currentpage;
echo '<a class="page bgcolor2" href="?pagenb=' . ($a-2) . '">' . ($a-2) . '</a>';
echo '<a class="page bgcolor2" href="?pagenb=' . ($a-1) . '">' . ($a-1) . '</a>';
echo '<a class="page bgcolor2" href="?pagenb=' . ($a) . '">' . ($a) . '</a>';
echo '<a class="page bgcolor2" href="?pagenb=' . ($a+1) . '">' . ($a+1) . '</a>';
echo '<a class="page bgcolor2" href="?pagenb=' . ($a+2) . '">' . ($a+2) . '</a>';
}
if ( $currentpage >= $pages-2 && $currentpage != "all" ) {
$a = $pages-2;
echo '<a class="page bgcolor2" href="?pagenb=' . ($a-2) . '">' . ($a-2) . '</a>';
echo '<a class="page bgcolor2" href="?pagenb=' . ($a-1) . '">' . ($a-1) . '</a>';
echo '<a class="page bgcolor2" href="?pagenb=' . ($a) . '">' . ($a) . '</a>';
echo '<a class="page bgcolor2" href="?pagenb=' . ($a+1) . '">' . ($a+1) . '</a>';
echo '<a class="page bgcolor2" href="?pagenb=' . ($a+2) . '">' . ($a+2) . '</a>';
}
我的尝试没有成功(没有错误但结果不同):
$pagenb = '<a class="page bgcolor2" href="?pagenb=' . ($a-2) . '">' . ($a-2) . '</a>
<a class="page bgcolor2" href="?pagenb=' . ($a-1) . '">' . ($a-1) . '</a>
<a class="page bgcolor2" href="?pagenb=' . ($a) . '">' . ($a) . '</a>
<a class="page bgcolor2" href="?pagenb=' . ($a+1) . '">' . ($a+1) . '</a>
<a class="page bgcolor2" href="?pagenb=' . ($a+2) . '">' . ($a+2) . '</a>';
if ( $currentpage <= 3 && $currentpage != "all" ) {
$a = 3;
echo $pagenb;
}
if ( $currentpage > 3 && $currentpage != "all" && $currentpage < $pages-2) {
$a = $currentpage;
echo $pagenb;
}
if ( $currentpage >= $pages-2 && $currentpage != "all" ) {
$a = $pages-2;
echo $pagenb;
}