Declaring a global variable inside a function

前端 未结 7 1960
误落风尘
误落风尘 2020-12-03 01:15

I have two PHP files. In the first I set a cookie based on a $_GET value, and then call a function which then sends this value on to the other file. This is s

相关标签:
7条回答
  • 2020-12-03 02:19

    The visibility of a variable

    I hope that helped

    <?php
    $a = 1;
    $b = 2;
    
    function Sum()
    {
        global $a, $b;
    
        $b = $a + $b;
    } 
    
    Sum();
    echo $b;
    ?>
    
    0 讨论(0)
提交回复
热议问题