PHP Programs

Program for Elseif example

In this program demonstrate use of else-if statement to check multiple conditions.

Else-if ladder are flow controls statement in which block of code execute only if condition satisfy.

Program

<html>

<head>

<title> Elseif...Example</title>

</head>

<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>

When Run The Program Following Output:

Have a nice day!

Description

In above program if today is Friday that time it prints "Have a nice weekend!" If day is Sunday then "Have a nice Sunday !" and if days other than Sunday and Friday then "Have a nice day!" will print on screen.

Releted Programs

© 2017 codewmAll rights reserved.