网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站设计 > PHP
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   IP: 180.125.23.91
Old 2016-02-28, 05:10 PM
Aniak Aniak is offline
初级会员
 
Join Date: 2008-08-10
Posts: 1
Aniak 现在声名狼藉
Default php 在使用if判断的时候 如果是多个逻辑或(||)条件 有没有简写的方法

如果条件太多无可避免的情况,即只能用if,就算用别的也感觉别扭不对劲的时候, 建议换一种写法:

if ($order['status'] == 9
|| $order['status'] == 10
|| $order['status'] == 11) {

}

我是花括号部另起一行党, 但在这种情况下,也可以

if ($order['status'] == 9
|| $order['status'] == 10
|| $order['status'] == 11)
{

}

另外建议把字面量常量放在左边。
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
X-Cart Multiple Input Validation Holes Permit SQL Injection and Cross-Site Scripting topvip X-Cart 0 2009-07-21 10:03 AM
用php语言来编写shell脚本 car 代码交流 0 2008-05-05 08:09 PM
Php教程.经验技巧(上) sunshine 代码交流 0 2006-12-15 08:13 PM
Php入门速成 smiling 代码交流 0 2006-12-15 07:30 PM
php.ini中文解释 sunshine 服务器环境搭建 0 2006-02-04 11:05 PM

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 11:08 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.