PHP 1.Write a php script that to displaythe Chinese Zodiac sign from 1-11. The C
ID: 3750251 • Letter: P
Question
PHP
1.Write a php script that to displaythe Chinese Zodiac sign from 1-11. The Chinese Zodiac sign is based on a twelve-year cycle, with each year represented by an animal –monkey,rooster, dog, pig, rat, ox, tiger, rabbit, dragon, snake, horse or sheep. Research the Zodiac sign “predictions”andprint them out. Make sure that you use loops (do, do/while, or for) in your script.Output:Year 1:MonkeyYear 2: RoosterYear 3: Dog2.Write a php script to display the current day and print an upliftingstatement for the day.Use the date function to figure out the day -date("D");Output:Today is Wednesday. “The pessimist sees difficulty in every opportunity. The optimist sees opportunity in every difficulty”~ Winston Churchill, Prime Minister of England during WWIIResearch and include seven quotes of your liking.You can also be creative and create a php solution of a real life application. Make sure you write a description of the php scripts that you are creating.
Explanation / Answer
Qn 1:
Qn 1:
<html>
<head>
<title> Chinese Zodiac</title>
</head>
<body>
<H3>Enter Your Zodiac year</H3>
<form method="post">
<input type="text" name="year">
<input type="submit" name="submit">
</form>
</body>
</html>
<?php
$year = (int)$_POST['year'] ?? 2018; //default year
$zodiac = "Please enter a valid year";
if(gettype($year) == 'integer'){
switch (($year - 4) % 12) {
case 0: $zodiac = 'Rat'; break;
case 1: $zodiac = 'Ox'; break;
case 2: $zodiac = 'Tiger'; break;
case 3: $zodiac = 'Rabbit'; break;
case 4: $zodiac = 'Dragon'; break;
case 5: $zodiac = 'Snake'; break;
case 6: $zodiac = 'Horse'; break;
case 7: $zodiac = 'Goat'; break;
case 8: $zodiac = 'Monkey'; break;
case 9: $zodiac = 'Rooster'; break;
case 10: $zodiac = 'Dog'; break;
case 11: $zodiac = 'Pig'; break;
}
}
echo "Year: $year and Zodiac : $zodiac";
?>
Qn 2:
<?php
$quotes = [
"Sun" => "The most courageous act is still to think for yourself. Aloud.--Coco Chanel",
"Mon" => "A goal is a dream with a deadline. --Napoleon Hill",
"Tue" => "An entrepreneur is someone who jumps off a cliff and builds a plane on the way down. --Reid Hoffman",
"Wed" => "I don't look to jump over seven-foot bars. I look for one-foot bars that I can step over. --Warren Buffet",
"Thu" => "You can't have a million dollar dream with a minimum wage work ethic. --Stephen Hogan",
"Fri" => "The most dangerous poison is the feeling of achievement. The antidote is to, every evening, think what can be done better tomorrow. --Ingvar Kamprad",
"Sat" => "The true sign of intelligence is not knowledge but imagination. --Albert Einstein"
];
$currDayFull = date("l");
echo "Today is ". $currDayFull .". ". $quotes[ date('D')]. "<br/>";
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.