示例#1
0
echo "<pre>";
function toArray($a, $b, $c)
{
    return [$a, $b, $c];
}
$u = toArray(1, 2)[0];
list($a, $b, $c) = toArray(1, 2, 3);
echo $u;
echo "<br>";
//print_r($u);
function mySum($a, $b)
{
    return $a + $b;
    echo "Этот код не выведется";
}
$s = mySum(5, 3);
echo $s;
echo "<br>";
function foo5()
{
    static $i = 0;
    echo ++$i . "<br>";
}
foo5();
foo5();
foo5();
foo5();
function sayHello($name, $role = 0)
{
    switch ($role) {
        case 0:
示例#2
0
function quizID($quiz_title, $course_title)
{
    $n = strlen($quiz_title);
    $id = first($course_title) . first($quiz_title) . $n * mySum($quiz_title);
    return "qz" . $id;
}