PHP中奇怪的打印行为? [英] Strange print behaviour in PHP?

查看:56
本文介绍了PHP中奇怪的打印行为?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么下面的代码输出128?

Why does the following code output 128?

<?php 
    print 4 << 5; 
?>

推荐答案

因为它是按位运算符.我认为这表示4乘以2 ^ 5,因为该运算符表示

Because it's a bitwise operator. I think it means 4 multiplied to 2^5 because that operator means

将$ a $ b步骤的位向左移动(每个步骤表示乘以 被两个")

Shift the bits of $a $b steps to the left (each step means "multiply by two")

这是五个步骤.是4 * 2 * 2 * 2 * 2 * 2(但是我在这里猜测;一切都发生在位级别).

so it's five steps. It's 4 * 2 * 2 * 2 * 2 * 2 (But I'm guessing here; everything happens at bit level).

这篇关于PHP中奇怪的打印行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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