Last active
February 26, 2018 19:39
-
-
Save justinhartman/e3c9fbda0573d37be6c2e996df49822a to your computer and use it in GitHub Desktop.
Embedded Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Ensure that the $age variable is set to null before running the myLife function. | |
*/ | |
$age = nil | |
/** | |
* This function returns a message to the user telling them how old they are. | |
* | |
* @param [int] $age Requires an integer value as an input. | |
* @return [string] Returns a message to the user displaying the input value. | |
* @author Justin Hartman <justin@hartman.me> | |
* @copyright Copyright 2017 Justin Hartman. All rights reserved. | |
* @category Users | |
* | |
*/ | |
function myLife($age) { | |
if (isset($age) && is_int($age)) { | |
echo "You are ".$age." years old." | |
} elseif (!isset($age)) { | |
echo "Please enter your age silly! We'd really like to get to know you better."; | |
} elseif (!is_int($age)) { | |
echo "Hmm, you won't believe this but I can't read your age. Tip, only use numbers when entering your age - e.g. 22."; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment