OR和||之间的功能差异 [英] Functional difference between OR and ||

查看:131
本文介绍了OR和||之间的功能差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

鉴于功能:


功能优先(){

echo" first \ n";

返回true;

}

函数second(){

echo" second\\\
" ;;

return true;

}

除了运算符优先级之外,是否有任何功能差异(

似乎不是任何): br />

if(first()|| second()){

echo" done\\\
";

}





if(first()OR second()){

echo" done\\\
;;

}


返回:


首先

完成

Daniel Klein

Given the functions:

function first() {
echo "first\n";
return true;
}
function second() {
echo "second\n";
return true;
}
Besides operator precedence, is there any functional difference (there
doesn''t appear to be any) between:

if (first() || second()) {
echo "done\n";
}

and

if (first() OR second()) {
echo "done\n";
}

Both return:

first
done
Daniel Klein

推荐答案

Daniel Klein写道:
Daniel Klein wrote:

鉴于功能:


函数优先(){

echo" first \ n" ;;

返回true;

}

函数second(){

echo" second\\\
" ;;

返回true;

}


除了运算符优先级,是否有任何功能差异(

似乎不是任何):


if(first()||第二个()){

echo" done\\\
";

}





if(first()OR second()){

echo" done\\\
" ;;

}

两次退货:


优先

完成


Daniel Klein
Given the functions:

function first() {
echo "first\n";
return true;
}
function second() {
echo "second\n";
return true;
}
Besides operator precedence, is there any functional difference (there
doesn''t appear to be any) between:

if (first() || second()) {
echo "done\n";
}

and

if (first() OR second()) {
echo "done\n";
}

Both return:

first
done
Daniel Klein



我甚至不知道你可以使用OR或AND。从手册:

I wasn''t even aware that you could use OR or AND. From the manual:


e = false ||真正; //
e = false || true; //


e将被分配给(false || true)这是真的
e will be assigned to (false || true) which is true


这篇关于OR和||之间的功能差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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