如何使OR(||)和AND(&&)语句一起工作?的PHP [英] How to get OR(||) and AND (&&) statements to work together? PHP

查看:93
本文介绍了如何使OR(||)和AND(&&)语句一起工作?的PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用此代码

if ($title != 'Main' || $nSpace == 56 || $nSpace == 30 && $ifHome != 361)

所以我选择了这个代码

if ($title != 'ArticleCategories' || $nSpace == 1)
    if ($nSpace == 0 && $ifHome != 1)

所以,我现在想知道如何将这两行合并成一行以使其起作用?我知道如何获得多个或||语句排成一行,但不是或||和&&&一起声明.

So, i am now wondering how can i get those two lines into one line in the way so that it works? I know how to get multiple or || statements into one line but not the or || and and && statements together.

推荐答案

使用括号将对程序有意义的逻辑组合在一起.

Use parens to group the logic together in a manner that makes sense for your program.

if ($title != 'Main' || $nSpace == 56 || ($nSpace == 30 && $ifHome != 361))

这篇关于如何使OR(||)和AND(&&)语句一起工作?的PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆