PHP Ternary Operator
by alamster in November 20th, 2006
PHP ternary operator isn’t beautiful for reading reason
It’s also make confuse, but for the sake of simple it’s OK
Syntax :
( expr1 ) ? ( expr2 ) : (expr3)
If expr1 return true, then it evaluates to ( expr2 )
If expr1 return false, then it evaluates to ( expr3 )
it’s similar to if..else
if(true) {
code 1
}
else {
code2
}
example :
// ternary operator
$year=2006;
$james_bond_title = ($year==2006) ? “Casino Royale” : ” I forgot “;
echo “James Bond Movie Title in 2006 is : $james_bond_title”;
//if … else
if($year==2006){
$james_bond_title=”Casino Royale”;
}
else {
$james_bond_title=”I forgot “;
}
echo $james_bond_title;
Which one is your favorite ?
Michael Jackson
Freelance Project:
- Require Fresh U.S ip 1k Youtube accounts by k00lcaptchrz
- Sale Page Graphic Header Needed by pispayton
- photoshop and logo design by kgarz31
- Boonex Dolphin Installation by austrainer
- MULTI-THREADED GMAILER by Quik
- Upgrade Interspire IEM 5.6.5 to 5.6.7 by rmyk
- VB.NET PRODUCT PLANNING APPLICATION by goolla
- Nonpublic project #462693 by carygd
- Female voice for audio files by eelrid
- Yahoo Account Creator Bot Needed by grap6b


No Comment
Random Post
Leave Your Comments Below