Neden küresel fonksiyon null?

0 Cevap

Ben bu garip sorunu olsun ....

All the page has this code only. global $currentPage; is null and i dont know why...

<?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>

SORUN

echo $currentPage; prints 1 
        function drawNumbers($from, $to) {
            global $currentPage;
           echo $currentPage; prints nothing

0 Cevap