我得到這個奇怪的問題....爲什麼全局函數爲null?
所有的頁面只有這個代碼。全球$ currentPage;全球$ ;爲空,我不知道爲什麼...
<?php
$pager = $_PARAMS["this"];
$pages = 5;
$currentPage = 1;
$tst="ap";
$nearPages = 5;
//Prologic
?>
<div class="pager">
<?php
$nearPagesHalf = ($nearPages - 1)/2;
drawNumbers(1, 1);
if ($currentPage - $nearPagesHalf <= 0) {
}
drawNumbers($pages, $pages);
?>
<?php
function drawNumbers($from, $to) {
global $currentPage;
for ($i = $from; $i <= $to; $i++) {
echo $currentPage;
if ($i == $currentPage) {
?> <span class="pageNumbers current"><?= $i ?></span>
<?php
} else {
?>
<a href="#">
<span class="pageNumbers"><?= $i ?></span>
</a>
<?php
}
}
?>
<?php
}
function drawDots($from, $to) {
}
?>
</div>
的問題
echo $currentPage; prints 1
function drawNumbers($from, $to) {
global $currentPage;
echo $currentPage; prints nothing
如果它是一個頁面的唯一代碼,那麼這個'$ pager = $ _PARAMS [「this」];'應該如何工作? – zerkms 2010-11-02 04:01:26