示例#1
0
function numbers_func($number)
{
    print $number;
    if ($number < 5) {
        numbers_func(++$number);
    }
}
示例#2
0
<?php

//завдання 1 .
function numbers_func($a = 0)
{
    for ($i = 1; $i <= $a; $i++) {
        print $i . ' ';
    }
}
numbers_func(5);
//завдання 2
function mult($a = 0)
{
    print '<table border="1" cellspacing="0">';
    for ($i = 1; $i <= $a; $i++) {
        print '<tr>';
        for ($x = 1; $x <= $a; $x++) {
            if ($i == 1 || $x == 1) {
                print "<td><strong>" . $i * $x . "</strong></td>";
            } else {
                print "<td>" . $i * $x . "</td>";
            }
        }
        print '</tr>';
    }
    print '</table>';
}
mult(20);
//завдання 3
function number_to_text($a = 0)
{
示例#3
0
<?php

function numbers_func($y)
{
    for ($x = 0; $x <= $y; $x++) {
        print $x;
    }
}
numbers_func(8);
示例#4
0
<?php

function numbers_func($y)
{
    $x = 0;
    do {
        $x++;
        print $x;
    } while ($x < $y);
}
numbers_func(10);
示例#5
0
<?php

function numbers_func($y)
{
    $x = 0;
    while ($x < $y) {
        $x++;
        print $x;
    }
}
numbers_func(15);