Saturday, November 28, 2020

If else statement in php.

 



In  if else structure we will examine a Boolean expression whether it is true or false.

If it is true the statements inside if block will be executed. If it is false the statements inside the else part is executed.

Sample1.php

<?php

$condition=true;

if($condition)

{

    echo 'this is true part'.'<br>';

    echo 'the condition is true'.'<br>';

    

}else{

    echo 'this is false part'.'<br>';

    echo 'the condition is part'.'<br>';

}

?>

 

 

Output:

this is true part
the condition is true

checking a variable is null or not null in php.

<?php

$name="Muthu karthikeyan";

if(!is_null($name))

{

    echo "name is defined <br>";

    echo "your name is $name <br>";

 

}

else{

    echo "name is not defined it is null";

}

?>

 

Output:

name is defined
your name is Muthu karthikeyan.

 

Checking using  isset function.

<?php

$name="Muthu karthikeyan";

if(isset($name))

{

    echo "name is defined <br>";

    echo "your name is $name <br>";

 

}

else{

    echo "name is not defined it is null";

}

?>

 

Output:

name is defined
your name is Muthu karthikeyan

checking using empty property.

<?php

$name="Muthu karthikeyan";

if(!empty($name))

{

    echo "name is defined <br>";

    echo "your name is $name <br>";

 

}

else{

    echo "name is not defined it is null";

}

?>

Output:

name is defined
your name is Muthu karthikeyan.

If condition using number value.

Sample3.php.

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

</head>

<body>

    <form action="vote.php">

    <P>  please Enter your age:

    <input type="text" name="txtAge" ></p>

    <P> <input type="submit" name="submit" value="submit">

    </p>

    

    </form>

</body>

</html>

Vote.php.

<?php

$age=$_REQUEST["txtAge"];

if ($age>=18){

 echo "your are eligible for vote";

}

 else{

 echo "not eligible for vote";

}

?>

 

 

Output:

 

 

 

 

Thank you

Muthu karthikeyan.

Contact:91 9629329142

Email:muthu.vaelai@gmail.com.

Madurai, Tamilnad, India.

 

Node js. Mini series. Part-1


 


Before the invent of node js java script is used only on the front-end for interacting with web pages. Node js  makes javascript to be executed on server side also.

Node js is the runtime environment and library for running java script application. We can use Node js for creating server side applications.

Down load location:

https://nodejs.org/en


 

It is used to run real time server applications.

It is an open source Environment.

Platform independent.

Node js files.

Node js files contain coding to do a particular task on certain events,  For example when you try to access a port on the server.

Node js files must be initiated on the server side.

Features of Node js.

1.       Very fast

2.       Asynchronous – non I/O blocking. It doesn’t wait between calls. It makes a request to server to get data and never wait for receiving data. It moves to the next request for data with out wait for  previous request’s response is finished. It makes Node js as Asynchronous and non I/O blocking.

3.       Single threaded.

4.       Scalable.

5.       No buffering.

6.       Open source.

 

Will continue:

By Muthu karthikeyan, free lance programming languages trainer.

contact:

91 9629329142.

Madurai, Tamil nad, India.

 email: muthu.vaelai@gmail.com