View Full Version : what is wrong with this code
xiaodao
12-04-2004, 11:33 AM
$show['status']==0?echo "<img src=\"images/approve.gif\">": echo '';
Maybe try the more readable and easier to debug variant:
// if you wanna check if $show['status'] is False
if (!$show['status']){
echo '<img src="./images/approve.gif">';
}
// if you wanna check if $show['status'] equals the value 0
if ($show['status']==='0'){
echo '<img src="./images/approve.gif">';
}
AaronW
12-04-2004, 03:01 PM
Ternaries are plenty readable I think...
echo $show['status'] === 0 ? '<img src="images/approve.gif">' : '';
I'd imagine your problem was == 0? "===" means "is equal to in both value AND type".
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.