PHP: Test a function

This entry is part 35 of 54 in the series PHP Tutorial

It is common to test a function or an expression in any programming language.

We can also test a function if the function would return a true or a false value.


function pocket_check($amount)
    $total_amt = $amount;

    if ($total_amt > 20) {
        return true;
    } else {
        return false;

$amount = 10;

if (pocket_check($amount)) {
    echo "I can go to a movie";
} else {
    echo "I can only stay at home";



Series Navigation<< PHP: Returning an array in a function
PHP: Apache Web & PHP server >>