Monday 2 February 2015

Trinary operator - PHP

<html>
<head>
<title>Using the ? Operator</title>
</head>
<body>
<?php
$mood 
= "sad";$text = ( $mood=="happy" ) ? "a good mood" : "Not happy but $mood";
print 
"$text";?></body>
</html> 

<?php
$first_num 
=2;$second_num = 1;
$max_num = $first_num > $second_num ? $first_num : $second_num;

echo(
$max_num);
?>

0 comments:

Post a Comment