PHP: Test a function

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.

<?php

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 >>