Friday, 28 August 2009

Php Tutorial Part 5




Conditional Statements


The IF Statement (most used in all programming languages)

Syntax:
if (condition)
{
//Code to be executed
}
elseif (Condition)
{

}
else
{

}

Example:
<html>
<body>

<?php
$number=15;
if ($number ==15)
{
echo "The number is 15";
}
elseif ($number >16)
{
echo "The number is greater than 16";
}
?>

</body>
</html>

The if statement is the most used Conditional statement, in php the condition must be surrounded by ( ) if you will execute 1 line of code you don’t have to surround the code with { } but I strongly suggest that you always surround the code with { }.

No comments:

Post a Comment

Reset numbering for Screenshots Win+PrtSc

I was using today the screen shot functionality of Windows 8.1 Win Key + PrtSc How to reset the numbering?