Tuesday 20 March 2012

ternary operator ?:

<html>
 <head>
 <title>Listing 5.5</title>
 </head>
 <body>
 <?php
 $mood = "sad";
 $text = ( $mood=="happy" )?"Hooray, I'm in a good mood":"Not happy but
$mood";
 print "$text";
 ?>
 </body>
 </html>
output
Not happy but sad

No comments:

Post a Comment