Jump to content

Using Functions in IF Statements


ManicMax

Recommended Posts

Example

<?php
function validDay ($d) {
    /**
    * assumes any value between 1-31 is valid
    */
    return ($d >=1) && ($d <= 31);
}

$day = 12;
if (validDay($day)) {
    echo "OK";
}
else {
    echo "Invalid";
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.