2010-08-08 82 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"; 
    } 
}