How to understand this judgment ((debug_mode 2) = = 2) _php Tutorial

Source: Internet
Author: User
How to understand this judgment ((Debug_mode & 2) = = 2)

((Debug_mode & 2) = = 2)//This sentence if set up, it is ((2 & 2) ==2) How to understand it?
Define (' Debug_mode ', false);//If 2 Yes, perform display 1

if ((Debug_mode & 2) = = 2)

{

$smarty = ' 1 ';

}

Else

{

$smarty = ' 0 ';

}

Echo $smarty;

?>

Copy code []


d8888d Huitie Content-------------------------------------------------------
"=&" What operator is this?
$user =& init_users ();
d8888d Huitie Content-------------------------------------------------------
is a reference, but adding & in front of the function really doesn't know what it's for.
d8888d Huitie Content-------------------------------------------------------
Bit operation and Operation Ah ...
d8888d Huitie Content-------------------------------------------------------
Let me explain.

In fact, the 2 here should be a fixed value, is to define your model of the constant, if this is good to understand

Define (' Mode_a ', 2);

$now _mode = 2;



if (($now _mode & mode_a) = = mode_a) {

echo "Current mode is Mode_a";

}

?>


Copy code Some classmates said, that why not = = Direct judgment, in fact, there is a meaning is included in the relationship
If the value of 6 & 2 is 2, and the value of 6&3 is 2, and 2! = 3
This approach can often represent a range, comparing the relationship between IP and subnet masks in a computer network
d8888d Huitie Content-------------------------------------------------------
Thanks to LS, your answer is well understood.
d8888d Huitie Content-------------------------------------------------------
Originally Posted by Lmhllr on 2007-12-17 17:27 [url=http://www.111cn.cn/bbs/redirect.php?goto=findpost&pid=335104&ptid= 46748] link marker [Img]http://www.111cn.cn/bbs/images/common/back.gif[/img][/url]
Bit operation and Operation Ah ...
Can you explain how he works? Or do you not understand the purpose of this writing?
d8888d Huitie Content-------------------------------------------------------
Originally Posted by Jayliu on 2007-12-17 16:55 [url=http://www.111cn.cn/bbs/redirect.php?goto=findpost&pid=335044&ptid= 46748] link marker [Img]http://www.111cn.cn/bbs/images/common/back.gif[/img][/url]
is a reference, but adding & in front of the function really doesn't know what it's for.
Added &
function return value is reference

PHP5 default is a reference, you can not use &amp, in PHP5 if the function directly return false, add & function is hung, PHP will not find the referenced address
d8888d Huitie Content-------------------------------------------------------
LS I learned something new. Thank you [img]http://www.111cn.cn/bbs/images/smilies/default/victory.gif[/img]
d8888d Huitie Content-------------------------------------------------------
Oh, that's it!

http://www.bkjia.com/PHPjc/632550.html www.bkjia.com true http://www.bkjia.com/PHPjc/632550.html techarticle How to understand this judgment ((debug_mode 2) = = 2)//This sentence if it is to be set up, it will be ((2//If 2 is, execute the display 1 if (Debug_mode} else {$smarty = ' 0 ';} echo $smarty;? &G T Copy ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.