这样就算会了PHP么?-2

时间:2021-10-08 15:00:34

学些关于函数FUNCTION方面的东东。。

感觉和PYTHON的APLLY功能差不多。。

<?php
    function come(){
        echo "来啦<p>";
    }
    function go($name = "jack"){
        echo "$name 走了<p>";
    }
    function back($string){
        echo "又回来了, $string<P>";
    }
    $func = "come";
    $func();
    $func="go";
    $func("Tome");
    $func="back";
    $func("Lily");
    function &test($tmp = 0){
        return $tmp;
    }
    $str = &test("看到了");
    echo $str."<p>";
    function example($num, $m, &$n){
        $m = $m * 5 + 10;
        echo "in function:\$m = ".$m;
        echo "<br>";
        $n = $n * 8 + 4;
        echo "in function:\$n = ".$n;
        echo "<br>";
        return "$num * $num = ".$num * $num;
    }
    $m = 1;
    $n = 10;
    echo example(10, $m, $n);
    echo "<br>";
    echo "out function: \$m = ".$m;
    echo "<br>";
    echo "out function: \$n = ".$n;
?>

这样就算会了PHP么?-2