Showing posts with label IF. Show all posts
Showing posts with label IF. Show all posts

Sunday, 21 September 2014

IF statement


Use the if statement to execute some code only if a specified condition is true. 

Syntax

if (condition) code to be executed if condition is true;


The following example will output "Have a nice weekend!" if the current day is Friday:

<html>

<body>


<?php

$d=date("D");

if ($d=="Fri") echo "Have a nice weekend!";

?>


</body>

</html>


Notice that there is no ..else.. in this syntax. You tell the browser to execute some code only if the specified condition is true.