Php Tutorial – CHAPTER 4: Let’s use some conditional statements
Condition statements are vital in every programming language and also
in scripting language like PHP. Let’s see some situation where we have
to perform conditional statements to solve some programmatic problems.
The following example will decide if tell you “have a wonderful day” or
“Be care in the weekend” depending on the current day of the week.
<Html> <head> <title> BRAND NEW PROGRAM </title> </head> <body> <span style="color: #ff0000;"><?php $d=date("D"); if ($d=="Fri") echo "Be care in the weekend!"; else echo "Have a wonderful day!"; ?></span> </body> </html>
You can experiment with other type of example that embrace almost the
same functionality like this:
<Html> <head> <title> BRAND NEW PROGRAM </title> </head> <body> <span style="color: #ff0000;"><?php $d=date("D"); if ($d=="Fri") { echo "Hi!<br />"; echo "Have a wonderful weekend!"; echo "I see you the next monday!"; } ?></span> </body> </html>
