Skip to content

Instantly share code, notes, and snippets.

@prondubuisi
Created June 28, 2019 11:50
Show Gist options
  • Save prondubuisi/1bd387751a8b356fa3ed01bfdafaad82 to your computer and use it in GitHub Desktop.
Save prondubuisi/1bd387751a8b356fa3ed01bfdafaad82 to your computer and use it in GitHub Desktop.
<?php
//Program to concatenate string of user input
$firstName = readline("Enter your first name ");
$lastName = readline("Enter your last name ");
$age = getAge();
$currentYear = date('Y');
$birthYear = $currentYear - (int) $age;
echo "Welcome, " . $firstName . " " . " " . $lastName . " (" . $birthYear . ")";
function getAge() {
do {
$age = readline("Enter your age ");
} while(!is_numeric($age));
return $age;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment