2014-09-21

Nested if statement

Use the if....elseif...else statement to select one of several blocks of code to be executed.

Syntax

if (condition)
code to be executed if condition is true;
elseif (condition)
code to be executed if condition is true;
else
code to be executed if condition is false;


Example

The following example will output "Have a nice weekend!" if the current day is Friday, and "Have a nice Sunday!" if the current day is Sunday. Otherwise it will output "Have a nice day!":

<html>
<body>

<?php
$d=date("D");
if ($d=="Fri")
echo "Have a nice weekend!";
elseif ($d=="Sun")
echo "Have a nice Sunday!";
else
echo "Have a nice day!";
?>

</body>
</html>

Related Posts:

  • PHP Syntax PHP code is executed on the server, and the plain HTML result is sent to the browser. Basic PHP SyntaxA PHP scripting block always starts with <… Read More
  • PHP Filter PHP filters are used to validate and filter data coming from insecure sources, like user input.What is a PHP Filter? A PHP filter is used to valida… Read More
  • How to setup wamp server in windows OSDownload the Wamp ServerDownload Link1Download Link2Download Link3 Install the Downloaded file Search Wamp and Open [follow 1st Image]  Clic… Read More
  • Read More
  • PHP IntroductionPHP is a server-side scripting language.  What is PHP?PHP stands for PHP: Hypertext PreprocessorPHP is a server-side scripting language, like AS… Read More

0 comments:

Post a Comment

Tools & Plugins

Blog Archive