Home > Backend Development > PHP Tutorial > php表达式中的 & 和| 分别什么意思啊?

php表达式中的 & 和| 分别什么意思啊?

WBOY
Release: 2016-06-06 20:39:57
Original
1427 people have browsed it

<code>$dly['print_status'] & 1

$dly['print_status'] | 1
</code>
Copy after login
Copy after login

分别什么意思啊?

回复内容:

<code>$dly['print_status'] & 1

$dly['print_status'] | 1
</code>
Copy after login
Copy after login

分别什么意思啊?

这个跟语言没关系,是二进制的与或运算,
一般用在权限管理里头。

位运算符,&1代表按位与,一般用来判断某个开关状态是否打开(如是不是打印成功了)
|1按位或,一般用于给某个开关状态设置为打开状态

http://php.net/manual/zh/language.operators.bitwise.php

请看葵花宝典

Related labels:
php
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template