PHP运算符<< [英] PHP Operator <<

查看:101
本文介绍了PHP运算符<<的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<<是什么?运算符在php中是什么意思?

What does the << Operator mean in php?

示例:

$t = 5;
$foo = 1 << ($t);
echo($foo); 

回声产生:32

谢谢

推荐答案

它是按位移位运算符.具体来说,是左移运算符.它采用左手参数,并将二进制表示形式向左移动右手参数指定的位数,例如:

It is the bitwise shift operator. Specifically, the left-shift operator. It takes the left-hand argument and shifts the binary representation to the left by the number of bits specified by the right-hand argument, for example:

1 << 2 = 4

因为1(十进制)是1(二进制);左移两次使它成为100,这是十进制的4.

because 1 (decimal) is 1 (binary); left-shift twice makes it 100 which is 4 in decimal.

1 << 5 = 32

因为二进制文件中的100000是十进制中的32.

because 100000 in binary is 32 in decimal.

右移(>>)的功能相同,但向右移动.

Right shift (>>) does the same thing but to the right.

这篇关于PHP运算符&lt;&lt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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