IF ELSE in PHP – PHP WEBSITE DEVELOPMENT

In this video

Today we are going to learn about IF ELSE in PHP. In our last lecture we learned about constants in PHP. If you haven’t watched it yet then here is the link of tutorial http://tutorialhive.net/2018/09/08/6-constants-in-php-php-website-development/  .Today’s tutorial is about constants in PHP.

IF ELSE in PHP

In this tutorial we will learn about IF ELSE in PHP . First step is to run wamp server. Run wamp and after that go into drive where you installed wamp server. Open folder Wamp after that open folder www. Now create a new folder in ‘www‘ you can give any name to your folder, I am naming it tutorialhive. In folder create a file with name index.php. In your editor open your php file.

Let’s suppose we have a scenario. when variable value is 22 we want to print your age is correct but if variable value is not 22 then it should print your age is not correct.

SYNTAX

if ( condition )

{

//here code that will run if condition is true

}

else

{

//here code that will run if condition is not true

}

<?php

$age=22;

if ($age = = 22)

{

echo “Your age is correct”;

}

else

{

echo “Your age is not correct”;

}

?>

Double equal sign is used for comparison purpose.

Output: Your age is correct

IF ELSE IF SYNTAX

If variable value is 22 or 23 then condition is true otherwise it is false.

<?php

$age=23;

if ($age = = 22)

{

echo “Your age is correct”;

}

else if ($age = = 23)

{

echo “Your age is correct”;

}

else

{

echo “Your age is not correct”;

}

?>

Output: Your age is correct

IF ELSE in PHP tutorial end here. In next tutorial we will learn about while and do while  in php. If you have any queries you can ask us on our Facebook page link is given below, Thank you for watching us.

ABOUT US

Tutorial Hive’s mission is to provide quality education to all our community. Tutorial Hive’s mission is to provide free education to all those who cannot afford BIG FEE of institutes. We aim specifically to empower youth to understand programming related knowledge which further helps the society to reduce complex problems through applications. Why Tutorial Hive? We not only provide the theoretical knowledge but also provide the actual implementation with working sample applications. Tutorial Hive cannot achieve its mission without the help of our community. So, please if you think you can help in any manner feel free to contact us. Or if you see any mistake in our content which can be modified/corrected then please leave us a message

We are always open for suggestions.

Facebook: www.facebook.com/hbss2015

Subscribe on YouTube: https://www.youtube.com/channel/UCOUy6kTpedj7s6HOqM0c08w

Follow us on Social Media

You might be interested in

LEAVE YOUR COMMENT

Your email address will not be published. Required fields are marked *