03
Feb
2011

IF, Else construct in PHP

Posted in: PHP No Comments

If, else construct is used to add logic in php code.

If else construct syntax

If (conditions)
{
// Code if condition is true
}
else
{
// Code if condition is false
}

It is similar like we have in C / C++ programming.

Example of a If else construct:

<?php
$a = 100;
if($a > 20)
{
echo "Yes $a is greater than 20";
}
else
{
echo "Sorry, $a is less than 20";
}
?>

About the Author

Name: Ravi Shekhar
Hi, I love designing WordPress Themes and Drupal Themes.

Share this post

Twitter Facebook Google Buzz Digg StumbleUpon Delicious Technorati

Leave a Reply