Conditional Operators
The table below
lists the conditional operator along with description and example.
Example:
Script:
Condition_op.php
<html>
<head>
<title>Condition Operators</title> </head>
<body>
<?php
$a = 15;
$b = 20;
echo
"a=".$a."</br>";
echo
"b=".$b."</br>"; /* If condition is true then assign
a to result otheriwse b */
$result = ($a
> $b ) ? $a :$b;
echo "a
greater than b condition result is: $result<br/>";
/* If condition
is true then assign a to result otheriwse b */
$result = ($a
< $b ) ? $a :$b;
echo "a less
than b conditional result is : $result<br/>";
?>
</body>
</html>
OUTPUT:
a=15
b=20
a greater than b
condition result is : 20
a less than b
condition result is : 15