Tuesday, April 17, 2012

Structure of the Special Conditions? in PHP

The following program is an example of using the structure of the special conditions? in PHP. The structure of these conditions can be applied to a simple examination of the conditions, such as IF ELSE.


<?php
$year = date ("Y");
$leap = ($year%4 == 0) ? "leap" : "not leap";
echo "year <b>$year</b> $leap";
?>


Explanation of Program:

In the program above, the function date () with parameter "Y" (row-2) will result in a 4-digit years now. In the third row will be checked if the variable $ year if dimodulus to 4 will result in a value of 0. If TRUE then $ leap will contain a "leap" and if FALSE $ leap will say "NOT a leap"

Related Posts by Categories

No comments:

Post a Comment