PHP Conditional Statements : If Else If Statements
What is PHP Conditional Statements?
when you write code, you want to perform different actions for different decisions.You can use conditional statements in your code to do this
- If : executes some code only if a specified condition is true
- if...else statement - executes some code if a condition is true and another code if the condition is false
- if...elseif....else statement - selects one of several blocks of code to be executed
If Example
if...else Example
Have a good night!if...elseif....else else Example
Have a good night! <html>
<head>
<title><?php $pagetitle="PHP Conditional Statements : If Else If Statements";
define("blogname","Samee Articles");
echo $pagetitle . ":" . blogname ?></title>
<meta name="description" content="<?php echo $pagetitle ?>" />
<meta name="robots" value="nofollow, noindex" />
<link rel="icon" type="image/ico" href="http://www.iconarchive.com/download/i50954/deleket/3d-cartoon-vol3/Web-Coding.ico" alt="Icon" />
<link type="text/css" href="stylesheet.css" rel="stylesheet" />
</head>
<body>
<div id="main">
<img id="logo" src="http://icons.iconarchive.com/icons/deleket/3d-cartoon-vol3/256/Web-Coding-icon.png" alt="Coding">
<h1 align="center"><?php echo $pagetitle ?></h1>
<h2 align="left">What is PHP Conditional Statements?</h2>
<?php
echo "when you write code, you want to perform different actions for different decisions.<br>
You can use conditional statements in your code to do this";
echo "<ol type=\"A\">
<li>If : executes some code only if a specified condition is true</li>
<li>if...else statement - executes some code if a condition is true and another code if the condition is false</li>
<li>if...elseif....else statement - selects one of several blocks of code to be executed</li>
</ol>";
?>
<h2 align="left">If Example</h2>
<?php
$t=date("H");
if ($t<"20")
{
echo "Have a good day!";
}
?>
<h2 align="left">if...else Example</h2>
<?php
$t=date("H");
if ($t<"20")
{
echo "Have a good day!";
}
else
{
echo "Have a good night!";
}
?>
<h2 align="left">if...elseif....else else Example</h2>
<?php
$t=date("H");
if ($t<"10")
{
echo "Have a good morning!";
}
elseif ($t<"20")
{
echo "Have a good day!";
}
else
{
echo "Have a good night!";
}
?>
<div id="sidebar">
<ul>
<li><?php echo "<a href=\"http://sameearticles.blogspot.com\">blogname</a>"?></li>
<li><a href="http://www.blogger.com/home">Blogger</a></li>
<li><a href="http://sameearticles.blogspot.com/search/label/PHP%20Learning">PHP Learning</a></li>
<li><a href="http://seoacquire.blogspot.com">SEO Knowledge</a></li>
<li>CSS Learning</li>
</ul>
</div>
</body>
</html>
Post a Comment
Give your reviews about this blog. Leave your comments. what do you think about this post?
Comments Description is given below:
1) I love to read comments, but do not spam.
2) Like this blog and also tweet its posts.
3) You can use some xHTML tags.
4) All Comments are Do Follow, Please try to use blog professionally.
5) Mention Your Name below the comment.
6) You can also suggest for improvement.
7) Do not forget to subscribe Samee Articles blog.
---------------------------------------
Thanks for visiting QWC.Me.
==========================================
For free guidelines contact me on SEO Expert | Samee Ullah Feroz is online there.
==========================================
Best Regards