【问题标题】:What does `<<` mean when declaring a variable in PHP? [duplicate]在 PHP 中声明变量时 `<<` 是什么意思? [复制]
【发布时间】:2013-02-08 08:50:55
【问题描述】:

当我注意到这一行时,我正在查看关于 facebook 的 HipHop 虚拟机 (HHVM) 的 this article

<?php
$u_bytes =
$p_bytes = 100 << 20;

我通过运行echo 100 &lt;&lt; 20; 对其进行了测试,结果为104857600。&lt;&lt; 20 是做什么的?


编辑

根据答案,它是按位运算符(位移位 [left])。示例:

100       = 000000000000000000001100100
                                ^ `<< 20` moves this bit 20 bits to the left
104857600 = 110010000000000000000000000

【问题讨论】:

标签: php hiphop


【解决方案1】:

这是bit shift left

您可以直接在 PHP 手册中了解更多关于它在 PHP 中的工作原理:http://php.net/manual/en/language.operators.bitwise.php

【讨论】:

    猜你喜欢
    • 2021-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-14
    • 1970-01-01
    • 2022-12-15
    相关资源
    最近更新 更多