2010-08-08 77 views
0

显示用户消息的任何建议,避免大量if/else语句的东西。如何显示用户消息

if($row->num_rows > 1) { 
    ok 
} else { 
print "There is no..."; 
} 

谢谢!

回答

1
$err = array(); 
if(!$row->num_rows > 1) { 
$err[]= "There is no..."; 
} 
... 
if (!$err) { 
    //ok. doing stuff 
} else { 
    foreach ($err as $message) { 
    echo $message."<br>\n"; 
    } 
}