PHP中出现Notice: Undefined variable: number1 in D:尀Wampserver2尀www尀3-10.php on line9 的问题

2024-12-19 11:00:53
推荐回答(1个)
回答1:


3-10


        $number1 = 20;
        function local()                //自订local函数
        {
            global $number1,$number2;
            $number2 = 30;
            echo "函数中$number1 = $number1";
            echo "
";
            echo "函数中\$number2 = $number2";
            echo "
";
            return $number2;
        }
        local();                        //自订local函数
        
        echo "函数中\$number1 = $number1";
        echo "
";
        echo "函数中\$number2 = $number2";
 ?>