Geeks Trick
Nested if else Statement In Python PHP and JS

Nested if else Statement In Python PHP and JS

In thus tutorial we will see Nested if else Statement In Python PHP and JS


The Python’s nested if…else statement

Let’s start with the best language i.e python ,
As every language have the similar logics but just have a difference in syntax.

Building up the nested if..else statement in python

if-else.py
name = "rehmaanali"
age = 12
if age > 10:
    print ("its true")
elif age == 12:
    print ("Exact")
else:
    print ("its false")

Python has dependencies that it should run on a python module
Where else in javascript, it builds in a browser.
Even the PHP has to be run on the localhost server, as PHP is a server programming.

The PHP nested if…else statement

PHP is the server programming that should be run on server using localhost server.
the code of php is written in php tags i.e
<?php /* YOUR CODE GOES HERE*/ ?>

Building up the nested if..else statement in php.

if-else.php
<?php
	$num = 12;
	if ($num > "10") {
		echo "Its true";
	} elseif ($num == "12") {
		echo "Exact!";
	} else {
		echo "its false";
	}
?>

The following code must be run on localhost server.

The javaScript nested if…else statement

The javaScript can be run on the local browser it does not depends on the localhost server. it can be run manually.

if-else.js
var msg = "";	
var age = 12;
   if (age > 10) {
       msg = "its true";
   } else if (time === 20) {
       msg = "Exact!";
   } else {
       msg = "its false";
   }

Rehmaanali

Hi This Is Rehmaanali.
Blogging Is Just A Hobby.
Graduate In Bsc Computer Science

Add comment

Author

Rehmaanali

Hi This Is Rehmaanali.
Blogging Is Just A Hobby.
Graduate In Bsc Computer Science

Subscribe To Our Newsletter

Join our mailing list to receive the latest Articles news and updates from our team. 

You have Successfully Subscribed!