How to use global variable in function in PHP

1 Answer

0 votes
function update_global_counter()
{
    global $counter;
    
    $counter++;
}
$counter = 100;
update_global_counter();
echo $counter; // 101


answered Apr 17, 2014 by avibootz

Related questions

1 answer 119 views
4 answers 368 views
3 answers 230 views
230 views asked Oct 17, 2015 by avibootz
3 answers 342 views
1 answer 160 views
...