Which is faster: Many Ifs, or Else if in PHP?
else if 是更好的选择。
以下是多个 if 语句的示例代码 −
if(condition_A){
//perform some action
}
if(condition_B){
//perform some action
}以下是 else if 语句的示例代码 −
if(condition_A){
//perform some action
}
else if(condition_B){
//perform some action
}使用 else if 语句时,如果一个条件得到满足,检查即会停止,并且与该条件关联的操作将被执行。以这种方式,操作和条件可以快速完成。
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP