Conditional Operator in Php


An operator is a symbol that represent a specific action.Operators are used to perform operations on variables and values.

Conditional Operator
Conditional operator contains
<   Less Than
>   Great Than
<=  Less Than Equal to
>=   Great Than Equal to
Example

<!DOCTYPE html>
<html>
<head><title>expertcodingmaster.com</title>
</head>
<body>
<?php
$Mukesh = 30;
$Ankita = 10;
$Prashant = 20;
if($Ankita < $Mukesh)
{
 echo "The marks of Mukesh is more than Ankita. <br>";
}
else
{
 echo "The marks of Ankita is more than Mukesh. <br>";
}
if($Ankita > $Prashant)
{
 echo "The marks of Ankita is more than Prashant. <br>";
}
else
{
 echo "The marks of Prashant is more than Ankita. <br>";
}
if($Mukesh <= ($Ankita + $Prashant))
 {
 echo "The marks of Mukesh is less than or equal to the sum of marks of Ankita and Prashant. <br>";
}
else
{
 echo "The marks of Mukesh is great than or equal to the sum of marks of Ankita and Prashant. <br>";
}
?>
</body>
</html>

Output of the above code
The marks of Mukesh is more than Ankita.

The marks of Prashant is more than Ankita.

The marks of Mukesh is less than or equal to the sum of marks of Ankita and Prashant. 

No comments: