Home Backend Development PHP Tutorial How to understand this judgment expression ((DEBUG_MODE 2) == 2)_PHP tutorial

How to understand this judgment expression ((DEBUG_MODE 2) == 2)_PHP tutorial

Jul 13, 2016 am 10:51 AM
debug mode judgment how established understand want this




How to understand this judgment expression ((DEBUG_MODE & 2) == 2)

((DEBUG_MODE & 2) == 2)//If this sentence is to be true, it must be ((2 & 2)==2). How do you understand this formula?
define('DEBUG_MODE',false);//If yes 2, execution will display 1

if ((DEBUG_MODE & 2) == 2)

{

$smarty = '1';

}

else

{

$smarty= '0';

}

echo $smarty;

?>

Copy code [ ]


D8888D reply content------------------------------------------------- ----------
"=&" What kind of operator is this?
$user =& init_users();
D8888D reply content------------------------------------------------- ----------
It’s a reference, but I don’t know what the use of adding & in front of the function is.
D8888D reply content------------------------------------------------- ----------
The AND operation in bit operations...
D8888D reply content------------------------------------------------- ----------
Let me explain

In fact, the 2 here should be a fixed value, a constant that defines your mode. It will be easier to understand if you write it like this

define('MODE_A',2);

$now_mode = 2;



if(($now_mode & MODE_A) == MODE_A){

echo "The current mode is MODE_A";

}

?>


Copy the code. Some students said, why not use == to judge directly? In fact, there is another meaning here, which is the included relationship
For example, the value of 6 & 2 is 2, and the value of 6&3 is also 2, and 2 != 3
This method can often represent a range. Compare the relationship between IP and subnet mask in computer networks to understand
D8888D reply content------------------------------------------------- ----------
Thank you LS, your answer is easy to understand.
D8888D reply content------------------------------------------------- ----------
Original post posted by lmhllr on 2007-12-17 17:27 [url=http://www.111cn.cn/bbs/redirect.php?goto=findpost&pid=335104&ptid=46748]Link tag[img]http:// www.111cn.cn/bbs/images/common/back.gif[/img][/url]
The AND operation in bit operations...
Can you explain its function? I still don’t understand the purpose of writing this way.
D8888D reply content------------------------------------------------- ----------
Original post by jayliu on 2007-12-17 16:55 [url=http://www.111cn.cn/bbs/redirect.php?goto=findpost&pid=335044&ptid=46748]Link tag[img]http:// www.111cn.cn/bbs/images/common/back.gif[/img][/url]
It’s a reference, but I don’t know what the use of adding & in front of the function is.
Added&
The function return value is a reference

PHP5 defaults to reference, and you cannot use & randomly. In PHP5, if the function directly returns false, the function with & will hang, and PHP will not be able to find the reference address
D8888D reply content------------------------------------------------- ----------
I learned something new from LS. Thank you[img]http://www.111cn.cn/bbs/images/smilies/default/victory.gif[/img]
D8888D reply content------------------------------------------------- ----------
So that’s it

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632550.htmlTechArticleHow to understand this judgment expression ((DEBUG_MODE 2) == 2)//If this sentence is to be true, it must be ((2 //If 2 is yes, execution displays 1 if ((DEBUG_MODE } else { $smarty= '0'; } echo $smarty; ?> Copy...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to identify genuine and fake shoe boxes of Nike shoes (master one trick to easily identify them) How to identify genuine and fake shoe boxes of Nike shoes (master one trick to easily identify them) Sep 02, 2024 pm 04:11 PM

As a world-renowned sports brand, Nike's shoes have attracted much attention. However, there are also a large number of counterfeit products on the market, including fake Nike shoe boxes. Distinguishing genuine shoe boxes from fake ones is crucial to protecting the rights and interests of consumers. This article will provide you with some simple and effective methods to help you distinguish between real and fake shoe boxes. 1: Outer packaging title By observing the outer packaging of Nike shoe boxes, you can find many subtle differences. Genuine Nike shoe boxes usually have high-quality paper materials that are smooth to the touch and have no obvious pungent smell. The fonts and logos on authentic shoe boxes are usually clear and detailed, and there are no blurs or color inconsistencies. 2: LOGO hot stamping title. The LOGO on Nike shoe boxes is usually hot stamping. The hot stamping part on the genuine shoe box will show

What is the resolution of Savior y7000p when playing CF (how to adjust the full screen when playing CF on Savior y7000) What is the resolution of Savior y7000p when playing CF (how to adjust the full screen when playing CF on Savior y7000) Jan 07, 2024 am 10:13 AM

What is the resolution of Savior Y7000P when playing CF? The resolution of Savior Y7000P when playing CF is 1920*1080. Because this computer is equipped with a GTX1650 graphics card and an i5-9300H processor, its performance is relatively good and sufficient to meet the needs of games such as CF. At the same time, 1920*1080 is the current resolution of mainstream e-sports monitors, and the image quality and clarity are sufficient. In addition, if there are players with higher requirements, you can appropriately lower the game image quality settings to obtain a smoother gaming experience. In order to enjoy a clearer visual experience, you can adjust the resolution of the Savior y7000p to 2560*1400. This way, you will be able to enjoy higher quality image display. Equipped with the Savior Y7000P 2022 model

How to determine whether a date is the previous day in Go language? How to determine whether a date is the previous day in Go language? Mar 24, 2024 am 10:09 AM

Question: How to determine whether the date is the previous day in Go language? In daily development, we often encounter situations where we need to determine whether the date is the previous day. In the Go language, we can implement this function through time calculation. The following will be combined with specific code examples to demonstrate how to determine whether the date is the previous day in Go language. First, we need to import the time package in the Go language. The code is as follows: import("time") Then, we define a function IsYest

jQuery usage practice: several ways to determine whether a variable is empty jQuery usage practice: several ways to determine whether a variable is empty Feb 27, 2024 pm 04:12 PM

jQuery is a JavaScript library widely used in web development. It provides many simple and convenient methods to operate web page elements and handle events. In actual development, we often encounter situations where we need to determine whether a variable is empty. This article will introduce several common methods of using jQuery to determine whether a variable is empty, and attach specific code examples. Method 1: Use the if statement to determine varstr="";if(str){co

How to tell if a jQuery element has a specific attribute? How to tell if a jQuery element has a specific attribute? Feb 29, 2024 am 09:03 AM

How to tell if a jQuery element has a specific attribute? When using jQuery to operate DOM elements, you often encounter situations where you need to determine whether an element has a specific attribute. In this case, we can easily implement this function with the help of the methods provided by jQuery. The following will introduce two commonly used methods to determine whether a jQuery element has specific attributes, and attach specific code examples. Method 1: Use the attr() method and typeof operator // to determine whether the element has a specific attribute

How to view and edit SQL files How to view and edit SQL files Feb 26, 2024 pm 05:12 PM

A SQL file is a text file that usually contains a series of SQL statements. To open a SQL file, you can use a text editor or a specialized SQL development tool. The easiest way to open a SQL file is with a text editor, such as Notepad or Notepad++ in Windows, or Text Editor in Mac. Here are the steps to open a SQL file: First, find the SQL file you want to open, right-click the file, and select "Open with". in the pop-up window

Magically modified 'Black Myth: Wukong ' to defeat Midjourney. This AI drawing tool is amazing. Magically modified 'Black Myth: Wukong ' to defeat Midjourney. This AI drawing tool is amazing. Aug 23, 2024 pm 09:42 PM

When AI Ideograms compete for realism and artistic sense, Ideogram has opened up a tricky track: it can accurately generate text on pictures, and the fonts and layouts are beautiful. This demand is not niche. Generate posters and illustrations with one click without using P-pictures. It can save a lot of trouble and is very suitable for ordinary people who know nothing about design. We previously wrote about version 1.0 of Ideogram. On August 21st, version 2.0 came. The realism is better, the posters are more designed, and the special skill of text is also stronger. You may have never heard of it. This is an AI product developed by former Google employees. It has many shortcomings, but the longboard can "overtake" Midjourney in corners. Directions https://ideogram.ai/A

How to determine if a field is empty in PHP? How to determine if a field is empty in PHP? Mar 20, 2024 pm 03:09 PM

PHP is a scripting language widely used in website development. For developers, it is often necessary to determine whether a field is empty. In PHP, determining whether a field is empty can be achieved through some simple methods. This article will introduce how to determine whether a field is empty in PHP, and provide specific code examples for your reference. In PHP, you can usually use the empty() function or isset() function to determine whether a field is empty. Next, we introduce the usage of these two functions respectively. Use the empty() function

See all articles